Timing out at 5500 rows

Topics: User Forum
Oct 4, 2010 at 3:10 AM
Edited Oct 4, 2010 at 3: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


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:


$objPHPExcel = new PHPExcel();

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


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


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?







Oct 4, 2010 at 9: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.