Laravel 6.0
If I understand Lazy Collections correctly, it cold be used to reduce the memory usage when exporting large datasets with laravel-excel.
Need more information to prepare an example.
I am not entirely sure how laravel-excel works under the hood, so I don't have a clue if this is a valid proposal - it's more of an idea.
I am not entirely sure how laravel-excel works under the hood, so I don't have a clue if this is a valid proposal - it's more of an idea.
In that case, you may check the Architecture documentation, which may clarify some of the concepts of Laravel Excel to you.
It would only be interesting if we could turn PhpSpreadsheets reading into a generator, which could be possible because it has an iterator. I'll leave this open as a future improvement. PR's are welcomed.
+1
@patrickbrouwers could you give me a hint on where I need to look at/start to implement the generator for PHPSpreadsheets?
I guess you can base yourself on the https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/tests/Concerns/FromGeneratorTest.php example
This was actually already possible when using the FromCollection concern:
public function collection() {
return new LazyCollection();
// or
return User::query()->cursor();
}
You used to be able to use a LazyCollection for queued exports, but since this commit, it's required to use a Collection. Is there a reason this method was changed to force users to use a Collection?
If we make the exportCollection method return Enumerable, that way you can pass a Collection or a LazyCollection.
Any Updates ? on lazy collections for laravel excel 3.1 or there are any other solutions for this big data export. Meanwhile shoulQueue with fromQuery concerns still get memory exceptions for big data export
This was actually already possible when using the FromCollection concern:
public function collection() { return new LazyCollection(); // or return User::query()->cursor(); }
Haven't seen any PR's, so no updates.
Most helpful comment
You used to be able to use a LazyCollection for queued exports, but since this commit, it's required to use a Collection. Is there a reason this method was changed to force users to use a Collection?
If we make the exportCollection method return Enumerable, that way you can pass a Collection or a LazyCollection.