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

[PROPOSAL] Allow exports with Lazy Collections #2344

Closed
Naoray opened this issue Aug 29, 2019 · 13 comments
Closed

[PROPOSAL] Allow exports with Lazy Collections #2344

Naoray opened this issue Aug 29, 2019 · 13 comments
Labels

Comments

@Naoray
Copy link
Contributor

Naoray commented Aug 29, 2019

Prerequisites

Laravel 6.0

Versions

  • PHP version: 7.2
  • Laravel version: 6.0
  • Package version:

Description

If I understand Lazy Collections correctly, it cold be used to reduce the memory usage when exporting large datasets with laravel-excel.

Example

Need more information to prepare an example.

Additional Information

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.

@GlennM
Copy link
Contributor

GlennM commented Aug 31, 2019

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.

@patrickbrouwers
Copy link
Member

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.

@lloricode
Copy link

+1

@Naoray
Copy link
Contributor Author

Naoray commented Nov 4, 2019

@patrickbrouwers could you give me a hint on where I need to look at/start to implement the generator for PHPSpreadsheets?

@patrickbrouwers
Copy link
Member

I guess you can base yourself on the https://github.com/Maatwebsite/Laravel-Excel/blob/3.1/tests/Concerns/FromGeneratorTest.php example

@patrickbrouwers
Copy link
Member

This was actually already possible when using the FromCollection concern:

public function collection() {
    return new LazyCollection();

    // or
    return User::query()->cursor();
}

@setharell
Copy link

setharell commented Jan 27, 2021

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.

@bCorps
Copy link

bCorps commented Apr 20, 2021

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();
}

@patrickbrouwers
Copy link
Member

Haven't seen any PR's, so no updates.

@nunodonato
Copy link

That commit had this absolutely needless change. I need to use LazyCollections but the interface doesn't allow me to and static checks fail. The whole package is rendered useless because of this...

@patrickbrouwers
Copy link
Member

patrickbrouwers commented Aug 17, 2023

Please be polite towards the efforts of everyone who has contributed towards this package. If you feel something should be improved, you have the option to PR it. Writing comments like this add absolutely no value.

@nunodonato
Copy link

@patrickbrouwers not my intention, sorry if the message came out feeling like that. I meant "rendered useless" for MY use case.

@patrickbrouwers
Copy link
Member

Like I said before - and already did 2 years ago - if you want to improve it for your use-case, you can PR it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants