使用Laravel FastExcel软件包导入大型Excel的内存有效方法是什么?

问题描述

我正在使用https://github.com/rap2hpoutre/fast-excel循环导入许多大型Excel文件

但是在此过程中,内存已耗尽。

以下是错误

2020-08-20 15:16:28 Saved 13867 records from file '/Users/akshaylokur/Work/GitHub/my-app/storage/app/my_excel.xlsx'.
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/akshaylokur/Work/GitHub/my-app/vendor/laravel/framework/src/Illuminate/Database/Connection.PHP on line 338

并提供以下代码段:

foreach ($files as $fileName) {

 $objs = (new FastExcel)->import($fileName,function ($line) {
                return MyModel::create([
                    'col_a' => $line['col_a'],'col_b' => $line['col_b'],.
                      .
                      .
                      .
                 ]);
      });
}

感谢任何线索,谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)