hardik
hardik

Reputation: 43

Fatal error: Allowed memory size exhausted when reading large excel files

I am getting below error while reading large .xls file say 29MB (3 sheets, 28000 rows/sheet) using Spreadsheet_Excel_Reader.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 71 bytes) in...

I changed memory_limit in php.ini to 128M, and also tried change it run time as ini_set('memory_limit', '-1'); for unlimited but error not solved.

Upvotes: 1

Views: 1792

Answers (3)

Lakin Mohapatra
Lakin Mohapatra

Reputation: 1135

Probably one server has a 64 bit processor. The GetInt4d bit shift doesn't work with 64 bit processors.

Use this hack to ensure correct result of the <<24 block on 32 and 64bit systems, just replace the code of the GetInt4d function with the following: Location : Excel/olereader.inc line no-27 ,function GetInt4d()

$_or_24 = ord($data[$pos+3]);

if ($_or_24>=128) $_ord_24 = -abs((256-$_or_24) << 24); else $_ord_24 = ($_or_24&127) << 24;

return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $_ord_24;

Upvotes: 0

Pratik
Pratik

Reputation: 810

ini_set('memory_limit', '-1'); overrides the default PHP memory limit

AND/OR

ini_set('max_execution_time', INCREASE TIME);

Upvotes: 0

Lo&#239;c
Lo&#239;c

Reputation: 11942

Not sure you could do '-1'.

You could try :

ini_set('memory_limit', '512M');

Upvotes: 0

Related Questions