PHPExcel_Writer_Excel2007::save() kills script for large data sets

Topics: Developer Forum
Nov 21, 2011 at 9:42 PM
Edited Nov 21, 2011 at 9:43 PM


Here's my PHP info:

- System:  FreeBSD 7.3-RELEASE-p4

- PHP Version: 5.2.17

- Default memory limit: 128M

- PHPExcel version: 1.7.6

I haven't been able to find a good answer to this searching, so here's my problem:

I have a data set of 2000 records, about 30 fields each, that I'm trying to convert to .xls.

However, while smaller sets of 1000 or less will write the .xls without a problem, my 2000-record set simply dies.  No error messages, no out of memory errors, just a blank page in Firefox, "Internet Explorer cannot display the webpage" in IE, "Server sent no data" in Chrome.

My script seems to go fine until this point, where the file is actually written:


$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
// die statement still shows up here
// die statement will not show if placed here


So I have to assume that the problem here is the $objWriter->save() function.  I don't think memory is an issue, as I have tried placing




before the save function and it shows a peak of 71303168 being used by the script, which is 50 mb less than the system default - for this script I have set the memory limit as high as 768mb with no success.

Is there anything that can be done about this, or at least any knowledge of what might be making this happen?  I saw a similar topic with no solutions offered other than "set you memory limit higher", but unless the save function is using 700mb, that is most definitely not the case here.

Thanks in advance for your help.

Feb 1, 2012 at 3:13 PM

Hi, I'm facing the very same problem. Have you solved it?

Feb 1, 2012 at 3:22 PM

I think it  is a memory problem, as the internal memory representation of your data gets copied to the output writer, which causes memory usage to rise. i solved this by buying 24GB of memory ;)


Try raising your memory limit, and see what it does. Also check the apache error log for crashes of php

Feb 1, 2012 at 7:48 PM

There's a lot of advice here on the forums about memory usage... I'm not going to repeat it all here, especially as the forum is searchable... but try using cell caching