Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpexcel Allowed memory size of 134217728 bytes exhausted [duplicate]

I am using phpexcel to write quite a large excel file.

I am writing it from an array that looks like

array(
  [0] => stdClass Object
        (
            [sent] => Mar 31st, 2011 02:10PM
            [to_number] => 64211111111
            [additional_txt] => 
            [misc_data] => 
        )
  ...
  [14058] => stdClass Object
        (
            [sent] => Mar 31st, 2011 02:10PM
            [to_number] => 64211111111
            [additional_txt] => 
            [misc_data] => 
        )
)

The loop is

$r = 0;
foreach ($replies_obj as $row) {
  $c = 'A';
  foreach ($row as $col)
    $xlsx->getActiveSheet()->setCellValue($c++ . $r, $col);
  $r++;
}

and the error is

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 105 bytes) in /home/webspace/xxxx/test/htdocs/application/libraries/PHPExcel/Worksheet.php on line 961

Is this a phpexcel problem or am I doing something wrong?

How can I fix this?

like image 403
Hailwood Avatar asked Apr 06 '11 00:04

Hailwood


1 Answers

There's a lot been written about PHPExcel and memory use, and I'm not going to repeat it all here.

Try reading some of the threads on the PHPExcel discussion board discussing the issue, such as this one; or previous answers here on SO such as this one or this one

like image 88
Mark Baker Avatar answered Nov 16 '22 04:11

Mark Baker