我需要知道,如果有減少使用內存時,創建一個PHPEXEL XLS的方式。這些文件有15000行。PHPExel創建XLS超載RAM
我有此腳本:
$payroll_incomes = $payroll_incomes->execute(null, Doctrine::HYDRATE_ARRAY);
$objPHPExcel->getActiveSheet()->fromArray($payroll_incomes[0], null, 'A1');
// Rename worksheet
$objPHPExcel->getActiveSheet()->setTitle('INGRESOS');
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="Ingresos.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output')
當我運行此腳本,我得到這個消息
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20 bytes) in /var/www/payroll/plugins/sfPhpExcelPlugin/lib/PHPExcel/PHPExcel/Worksheet.php on line 962
謝謝!
UPDATE
我加入這個代碼行:
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
$cacheSettings = array(' memoryCacheSize ' => '10KB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
$objPHPExcel = new PHPExcel();
所以它的工作exelent :)
哪條線是線962? –
兩種選擇:通過線1.運行更少。它可以在幾個小批量中完成嗎? 2.聯繫PHPExcel開發人員。 – Sammitch
@Sammitch我該怎麼辦較小的批次? – JERC