Laravel-excel: [QUESTION]limit the number of result in an export with FromQuery

Created on 21 Nov 2019  路  3Comments  路  Source: Maatwebsite/Laravel-Excel

Prerequisites

Versions

  • PHP version: 7.3
  • Laravel version: 5.7
  • Package version: 3.1.12

Description

I would like to have a way to limit the number of total result in an export. Like we can chunk, I would like that there is an absolute limit in terms of the number of result the export can do with a fromQuery (I know that with an iterator, a collection or whatever I can do some limitation but I don't know why I would do something like this if it's kind easy to add)

Additional Information

If it's not possible (I didn't see anything, but perhaps I miss one) I would like to add something similar to this..

probably in \Maatwebsite\Excel\Sheet::fromQuery adding something like this

if ($sheetExport implements WithLimit) {
   // ... if limit reach then stop looping
}
question

Most helpful comment

For info (if someone find this), to solve this issue that's more new feature now
I use FromIterator interface, with LimitIterator and a query builder that generate the result through an iterator.

All 3 comments

There's no limiting hard cut off currently. You could limit the query by using a where, e.g. on last id.

For info (if someone find this), to solve this issue that's more new feature now
I use FromIterator interface, with LimitIterator and a query builder that generate the result through an iterator.

For info (if someone find this), to solve this issue that's more new feature now
I use FromIterator interface, with LimitIterator and a query builder that generate the result through an iterator.

Do you have an example of you use it?

Was this page helpful?
0 / 5 - 0 ratings