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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?