doutan5724 2015-05-05 04:35
浏览 58
已采纳

PHPExcel按原样写行,没有任何计算/样式

Is there a way to tell PHPExcel to just write rows supplied from an array, without doing any calculation / apply styling / any other thing it does while writing OR when using fromArray ?

Need this for performance.

        $inputFileName = 'client_files/sample.xlsx';
        $objPHPExcel = PHPExcel_IOFactory::load($inputFileName);

        $objPHPExcel->getSheet(0)->setCellValue('D2', '@' . $user . ' followers');
        $objPHPExcel->getSheet(0)->fromArray(
            $followersData,
            NULL,
            'A5'
        );
        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
        $objWriter->setPreCalculateFormulas(false);

        $objWriter->save(FINAL_FOLDER . '/' . $line[0] . '.xlsx');

Memory consumption isn't an issue. But the above is just taking too much time (2 minutes with 2700 rows)

the ->save() call takes 93 seconds. The ->fromArray() takes 53 seconds

Also is there any other wayy faster Excel library that allows loading existing xlsx and then writing to it ?

Thanks

  • 写回答

2条回答 默认 最新

  • dongze8698 2015-05-06 12:32
    关注

    I did a bunch of things that resulted in wayyyy faster performance.

    1. ran the script outside the IDE
    2. set memory limit to 3GB
    3. Used a different version of PHP
    4. Fixed memory leak

      $objPHPExcel->disconnectWorksheets() ;
      unset($objPHPExcel) ;
      

    I am not sure what solved the issue..

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

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