dongxia4880 2010-12-22 13:17
浏览 104
已采纳

PHPExcel一次在多个工作表上设置相同的属性,内容等

Is there anyway to set the same properties (colors, row height, alignments) and content (hear names) for all sheets at once with PHPExcel? How?

Thank you.

  • 写回答

1条回答 默认 最新

  • doutang8098 2010-12-22 13:29
    关注

    If you're creating all those sheets yourself. Set the properties for the first sheet that you create, then clone that sheet and attach the new clone back to the same workbook. This should copy all existing cell data and style information from the original worksheet.

    //  Create a new PHPExcel object with a single sheet
    $objPHPExcel = new PHPExcel();
    
    //  Set any styles here against the currently active sheet in $objPHPExcel
    
    //  Get the current sheet with all its newly-set style properties
    $objWorkSheetBase = $objPHPExcel->getSheet();
    
    //  Create a clone of the current sheet, with all its style properties
    $objWorkSheet1 = clone $objWorkSheetBase;
    //  Set the newly-cloned sheet title
    $objWorkSheet1->setTitle('Cloned Sheet');
    //  Attach the newly-cloned sheet to the $objPHPExcel workbook
    $objPHPExcel->addSheet($objWorkSheet1);
    

    It's useful to note that you can set styles for a cell even before you write data to that cell

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据