PHPExcel memory usage

Topics: Developer Forum
Apr 6, 2009 at 2:29 PM
I'm sorry to say this about such a promising project, but you guys really need to figure out this excessive memory usage problem.

I attempted to use your library in a project of mine with a test data set of 1000 rows and about 49 columns.  I was using no formatting, no styling, no special data types (only string), and trying to output in Excel 2007.  I used the sample code for setting up the writer factories etc.  The memory usage was horrible, between the writing data to the sheet and ouputting it, I used 48 megabytes.   I switched all my project code out to use the Pear Spreadsheet_Writer and now memory usage is about 1.2 megabytes.  The net effect is now I can output much larger spreadsheets.

I couldn't even use this library on data-sets larger than 3k rows, it would blow up with out of memory errors at 228 megabytes.  That is just ridiculous. 

I could not find the wasteful memory usage, although I traced and traced.
Apr 6, 2009 at 2:54 PM
I have to agree 100%.  I've been working on a project that requires MUCH larger files than thetazzbot is referring to, but I don't see why the class (designed my Microsoft, no less) doesn't even allow you to write a basic spreadsheet with a large number of rows.  I've been looking around at your code and it has occurred to me that this isn't going to be a simple task to fix, because the entire design of your app rest on creating that PHP Excel object and then passing it to a writer.  That object is obviously huge.  Reguardless of how it is implemented, and at this point a completely seperate object/library might be neccessary, the community needs the ability to write data in a way that doesn't consume so much memory.
Apr 6, 2009 at 5:08 PM
It's not written "by microsoft".  This is just a service Microsoft provides, they do not "own" all of the projects hosted here.

Nonethess, this bug has to by fixed else this is not production ready code and should be tagged as Beta.
Coordinator
Apr 6, 2009 at 6:23 PM
We are not a Microsoft project. Codeplex is just a project hosting website that is provided by Microsoft, but they have nothing to do with the projects themselves.

For our 1.6.7 release (we hope to get it in in time), we are doing some investments in reducing memory usage and improving speed. This is mainly caused by circular references in PHP not being handled correctly by the parser. We are now working on a rewrite of the PHPExcel_Style_* classes to prevent this behaviour from happening, sharing styles between multiple cells automatically.

Related work item: http://phpexcel.codeplex.com/WorkItem/View.aspx?WorkItemId=6857

Another thing we are working on is an improved version of the formula parser, providing faster and more accurate results for formula calculation. Related work items can be found here: http://phpexcel.codeplex.com/WorkItem/AdvancedList.aspx