How can I resolve “Allowed memory size exhausted” error?

前端 未结 1 578
悲&欢浪女
悲&欢浪女 2021-01-22 04:18

I´m working with phpspreadsheet and I want to modify an xlsx file with 4 sheets. I only want to insert data in 2 sheets, but I want to copy all 4 sheets to the new xlsx file. Wh

1条回答
  •  温柔的废话
    2021-01-22 04:45

    Finally I have found the solution. The problem was on the writer and the formulas, so have add this line to the code and now it works well:

    $writer->setPreCalculateFormulas(false);
    

    So the all the code for the writer now is:

    $writer = new Xlsx($spreadsheet);
    $writer->setPreCalculateFormulas(false);
    $writer->save('test.xlsx');
    

    0 讨论(0)
提交回复
热议问题