FATAL: erealloc(): Unable to allocate 100663296 bytes

Sep 25, 2008 at 1:01 AM
i get this error when attempting to load a 5MB excel sheet that contains around 40 worksheets.

$objReader = new PHPExcel_Reader_Excel5('Excel2005');
$objPHPExcel = $objReader->load("myexcelsheet.xls");

I tried increasing the memory_limit in php.ini but still had the same error.
Is there another setting I need to increase?

Also, is there a way to specify a specific worksheet in the initial load() function rather than getSheet()?

Thanks in advance

Developer
Sep 25, 2008 at 1:25 AM
If you don't need style information, but only data.

$objReader->setReadDataOnly(true);

To load specific sheet only:

$objReader->setLoadOnlySheets('mySheet');

or mulitple sheets

$objReader->setLoadOnlySheets(array('mySheet', 'anotherSheet'));

Any of the above will help reducing memory consumption.

For the loading specific sheets, you need latest source (1.6.3 won't do):
http://www.codeplex.com/PHPExcel/SourceControl/ListDownloadableCommits.aspx

See also:
http://www.codeplex.com/PHPExcel/WorkItem/View.aspx?WorkItemId=7557

Sep 25, 2008 at 2:55 PM
Another way:

if you want only to read data - CSV format is the best way (memory and time)