php phpexcel 允许的内存大小为 134217728 字节已用完

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5560053/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 21:48:23  来源:igfitidea点击:

phpexcel Allowed memory size of 134217728 bytes exhausted

phparraysmemoryphpexcel

提问by Hailwood

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

我正在使用 phpexcel 编写相当大的 excel 文件。

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

致命错误:第 961 行的 /home/webspace/xxxx/test/htdocs/application/libraries/PHPExcel/Worksheet.php 中允许的内存大小为 134217728 字节(试图分配 105 字节)

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

这是一个phpexcel问题还是我做错了什么?

How can I fix this?

我怎样才能解决这个问题?

回答by Mark Baker

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

有很多关于 PHPExcel 和内存使用的文章,我不会在这里重复。

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 oneor this one

尝试阅读 PHPExcel 讨论板上讨论该问题的一些线程,例如这个;或以前在 SO 上的答案,例如this onethis one