Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Allowed memory size. Bug or not? #2585

Closed
4 tasks done
valeriy-efimov opened this issue Mar 10, 2020 · 9 comments
Closed
4 tasks done

[QUESTION] Allowed memory size. Bug or not? #2585

valeriy-efimov opened this issue Mar 10, 2020 · 9 comments

Comments

@valeriy-efimov
Copy link

valeriy-efimov commented Mar 10, 2020

Prerequisites

Versions

  • PHP version: 7.1
  • Laravel version: 5.5.*
  • Package version: ^3.0

Description

got error
image

Additional Information

memory_limit = 1536M - I can’t set more
my code
image

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

$data it collection data with 500000 rows +
How can i write so much data ?

@valeriy-efimov valeriy-efimov changed the title Allowed memory size. Bug or not? [QUESTION] Allowed memory size. Bug or not? Mar 10, 2020
@patrickbrouwers
Copy link
Member

Your PHP process runs out of memory when reading your view file. I think 500000 rows is a bit too much for the FromView strategy. You can try the approach this article took: https://stefanzweifel.io/posts/lazy-collections-in-laravel-excel/

@valeriy-efimov
Copy link
Author

valeriy-efimov commented Mar 11, 2020

Your PHP process runs out of memory when reading your view file. I think 500000 rows is a bit too much for the FromView strategy. You can try the approach this article took: https://stefanzweifel.io/posts/lazy-collections-in-laravel-excel/

I cant use cursor() because use Laravel version: 5.5.*. And I get the data not only from database, through calculations in php, because the database does not allow such calculations. In any case, I will have an array with 500,000 rows, before I give it to the generator Excel file.

@fedeisas
Copy link

@patrickbrouwers I tried the approach from the article but I get:

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

@patrickbrouwers
Copy link
Member

@fedeisas which version of laravel are you using?

@fedeisas
Copy link

fedeisas commented Mar 19, 2020

@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

@fedeisas
Copy link

fedeisas commented Mar 19, 2020

I'm using queued writes. Maybe that's the issue?

I'm trying to do exports on distributed workers (using S3) and the FromQuery is painfully slow (1 hour for a 30k rows export).

So I'm trying to switch to lazy collections and cursor() with no luck.

@Observer5
Copy link

@fedeisas use queue failed with error
Return value of Maatwebsite\Excel\QueuedWriter::exportCollection() must be an instance of Illuminate\Support\Collection, instance of Illuminate\Support\LazyCollection returned
but Excel::download is OK

@noorelbahr
Copy link

noorelbahr commented Sep 3, 2020

i still can't export 60K data with FromQuery concern or LazyCollection with 512M memory setting

any other setting to implement this?
https://stefanzweifel.io/posts/lazy-collections-in-laravel-excel/

@stale stale bot added the stale label May 30, 2021
@stale
Copy link

stale bot commented May 31, 2021

This bug report has been automatically closed because it has not had recent activity. If this is still an active bug, please comment to reopen. Thank you for your contributions.

@stale stale bot closed this as completed May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants