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条)

报告相同问题?

悬赏问题

  • ¥40 图书信息管理系统程序编写
  • ¥15 7-1 jmu-java-m02-使用二维数组存储多元线性方程组
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题