Timing out at 5500 rows

Topics: User Forum
Oct 4, 2010 at 4:10 AM
Edited Oct 4, 2010 at 4:11 AM

Hi Guys

I've got PHPExcel 1.7.4 running on a CentOS server and trying to generate financial reports from a MySQL database.

My query is returning about 5,500 rows and runs in about 10-15 seconds, but the PHPExcel output seems to stall at the line

$objWriter->setTempDir($server_path.'tmp');

and hits the 300 second timeout limit.

Server info:

PHP Version 5.2.8

Linux 2.6.9-89.0.20.EL 

My script starts with:

ini_set("memory_limit","512M");

$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);

My columns run from A to Y and about 10 of them have formatted columns like this:

$objPHPExcel->getActiveSheet()->getStyle('W')->getNumberFormat()->setFormatCode('$#,##0.00');
$objPHPExcel->getActiveSheet()->getStyle('K')->getNumberFormat()->setFormatCode('#,##0');

Once I've retrieved the rows and populated the cells I call this:


header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'.xls"');
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header ('Cache-Control: cache, must-revalidate');
header ('Pragma: public');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');

At which point maybe 20-30 seconds have elapsed

$objWriter->setTempDir($server_path.'tmp');
$objWriter->save('php://output');

These last two lines take forever (yes tmp does exist) and time out the server.

PHP Fatal error: Maximum execution time of 300 seconds exceeded in/httpsdocs/PHPExcel/Writer/Excel5/BIFFwriter.php on line 151

Is this just a resource problem and I need to look at caching or is there something else I can do?

 

Cheers

 

Lucas

 

 

Coordinator
Oct 4, 2010 at 10:12 PM

Cell caching won't help, that reduces memory usage but at a cost in speed.

$objWriter->setTempDir($server_path.'tmp'); won't help. Again, it reduces memory usage at a cost in speed.

I can't really explain why it's taking so long to save the file... other than to say it shouldn't take that long.