Laravel-excel: [问题]允许的内存大小。 有没有bug?

创建于 2020-03-10  ·  8评论  ·  资料来源: Maatwebsite/Laravel-Excel

先决条件

  • [x]已阅读并理解: https :
  • [x]检查您的Laravel Excel版本是否仍然受支持: https ://docs.laravel-excel.com/3.1/getting-started/support.html#supported -versions
  • [x]检查了您的问题之前是否尚未提出。
  • [x]填写了整个问题模板

版本号

  • PHP版本:7.1
  • Laravel版本:5.5。*
  • 套件版本:^ 3.0

描述

出错了
image

附加信息

memory_limit = 1536M-我无法设置更多
我的代码
image

Excel::download(new ReportExport($data), 'excel.xlsx');

$data it收集具有500000行的数据+
我该如何写入这么多数据?

question

最有用的评论

@fedeisas使用队列失败,出现错误
Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned
但是Excel :: download可以

所有8条评论

读取视图文件时,您的PHP进程内存不足。 我认为500000行对于FromView策略来说有点过多。 您可以尝试本文采用的方法: https :

读取视图文件时,您的PHP进程内存不足。 我认为500000行对于FromView策略来说有点过多。 您可以尝试本文采用的方法: https :

我不能使用cursor(),因为使用的是Laravel版本:5.5。*。 而且我不仅通过php中的计算从数据库中获取数据,因为数据库不允许进行此类计算。 无论如何,在将其提供给生成器Excel文件之前,我将拥有一个包含500,000行的数组。

@patrickbrouwers我尝试了本文中的方法,但得到了:

Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned

@fedeisas您使用的是哪个版本的laravel?

@patrickbrouwers

laravel/framework                            v6.18.1            The Laravel Framework.
maatwebsite/excel                            3.1.19             Supercharged Excel exports and imports in Laravel
phpoffice/phpspreadsheet                     1.11.0             PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

我正在使用排队写操作。 也许这就是问题吗?

我正在尝试对分布式工作者进行导出(使用S3),而FromQuery的速度非常慢(1万行导出1小时)。

因此,我尝试切换到懒惰的收藏和cursor()没有运气。

@fedeisas使用队列失败,出现错误
Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned
但是Excel :: download可以

我仍然无法使用FromQuery或512M内存设置的LazyCollection导出60K数据

还有其他设置可以实现吗?
https://stefanzweifel.io/posts/lazy-collections-in-laravel-excel/

此页面是否有帮助?
0 / 5 - 0 等级