How to write directly without using a lot of memory, also improve processing time?

Topics: User Forum
Jul 28, 2014 at 9:35 PM

I need to write a large XLS spreadsheet, but I have no need to actually hold rows I already wrote in memory. The spreadsheet is extremely basic (no styling requirements) but I do use a custom cell handler to write some cells out as text. The spreadsheet is something around 40x10000 with probably 40-60% blank cells. I can write it out in around 45 seconds but it does require me to raise the memory limit beyond 128M. I am outputting the spreadsheet as an attachment in the browser. The spreadsheet winds up being around 4MB. There are no formulas or calculations.

Is it possibly to simply "write out" as I go?

How can I decrease the time it takes to write?

I would basically like to "write and forget", if that makes any sense.
Jul 28, 2014 at 10:35 PM
Then don't use PHPExcel: MS Excel file formats simply aren't suited to "write out as you go"
instead simply write out as a CSV file using PHP's built-in fputcsv().