problem with reading large excel files

Topics: User Forum
Mar 16, 2009 at 7:06 AM
 I have a problem (and probably I'm not the first one with such problem. couldn't find post that
specifically tied up to my problem) - need to read excel 2003 file with
size around 800-850kb - your library runs out of memory. After reading some of the related posts here and trying to
 increase memory usage in php.ini to memory_limit = 128M (that didn't help) , I realize that its probably won't be solved
until library code is fixed , but still .. can I do anything to fix it? known workarounds perhaps? Am I right to guess that kind
of file size limit exist that this library can read from?
Mar 16, 2009 at 1:46 PM
You are correct that this library uses vast amounts of memory. This is a high-priority issue we're trying to get solved at this moment.

Some tips for now:

1. When reading the Excel file, one is often only interested in the cell data and not the styles. Do like this to reduce memory consumption:

$objReader = PHPExcel_IOFactory::createReader('Excel5');

2. Check how much memory you are using. Put this at the end of your script:

echo date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";

Try to split your Excel file until it starts loading successfully within the memory_limit. This will give you some idea what size file you can read on your system.

Mar 16, 2009 at 7:05 PM
Many many thanks , Koyama. Your advice to add "$objReader->setReadDataOnly(true);" did the trick :
  from exceeding memory limits (limit was 128mb) memory usage went down to ~37mb and the library worked as it should have.
Since I needed to read excel file data to import its contents to MySQL database , that was exactly what I needed.

Thank you for your awesome work!