出错了
memory_limit = 1536M-我无法设置更多
我的代码
Excel::download(new ReportExport($data), 'excel.xlsx');
$data
it收集具有500000行的数据+
我该如何写入这么多数据?
读取视图文件时,您的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/
最有用的评论
@fedeisas使用队列失败,出现错误
Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned
但是Excel :: download可以