Memory usage exceeds 2GB!!!!

Topics: Developer Forum, User Forum
Jan 13, 2009 at 11:40 PM
Hi there,

We are having some serious memory issues with larger excel sheets in the Excel2007 format. We have an excel sheet that contains 3600 rows and 150 cols and takes 2.5GB of memory! The writer typically dies to Style.php and it appears that the style object is created for each cell, instead of reusing the style object. We only do styles on the header line, however we do number formatting on almost all the cells which I believe falls under the style object as well. Does anyone know if there are any work around at the moment? Has anyone benchmarked the memory use? There is a disk caching option, will this flush the object to the disk (XML) freeing up used memory?

Thanks for all your comments / suggestions!
Jan 14, 2009 at 12:12 AM
Take a look at 23sharedstyles.php in the Tests folder in the PHPExcel 1.6.5 download. You can use shared styles for your cells. This should significantly reduce memory consumption, but I haven't done much testing, so I don't have first-hand experience with this.

Note that while you are using shared styles, then manipulation of cell styles using e.g. getStyle('A1') may not work as expected. You will be manipulating the style for all cells which share the style of cell 'A1'. However, I don't think that this will be a problem in your case.

Because of the above discreapancy with shared styles, it is not the default way of handling styles in PHPExcel. It is much more complicated to tackle with shared styles in a library that features both a reader and a writer. We are fully aware that this needs to be solved: