pxlrbt / filament-excel

Excel Export for Filament Admin Resources
MIT License
355 stars 68 forks source link

Exporting Excel of large amount of data #111

Closed Umar-Farooq-Shafi closed 1 year ago

Umar-Farooq-Shafi commented 1 year ago

Hey, I've data about 40K when I try to export the file. The browser got stuck and didn't respond even when I tried to export using ->queue() and ->withChunkSize() and set the size from 100 to 20K but it didn't work.

ExportBulkAction::make()->exports([
   ExcelExport::make('table')
          ->queue()
          ->withChunkSize(20000)
           ->fromTable(),
])
pxlrbt commented 1 year ago

You shouldn't use a BulkAction with that many records, because the BulkAction needs to send all 40k ids of your records to the backend which is what's probably causing the browser to crash/get stuck.

Best to use a Table Header Action in this case.

Umar-Farooq-Shafi commented 1 year ago

@pxlrbt Thanks, it's working.

Umar-Farooq-Shafi commented 1 year ago

What is the best size withChunkSize?

pxlrbt commented 1 year ago

What is the best size withChunkSize?

I don't really now. I'd say something around 1000?

Umar-Farooq-Shafi commented 1 year ago

@pxlrbt The issue with the Table Header Action is that I have to filter out the record based on the date range but it's not applying on the Export. it's downloading all the records.

Screen Shot 2023-09-01 at 1 15 37 PM
pxlrbt commented 1 year ago

You could use ->modifyQuery(fn ($livewire) -> ) to apply your filters. Haven't implemented that one yet apparently. But somebody else reported an issue with Depedency Injection into Closures. So for now there might be no solution to this

Umar-Farooq-Shafi commented 1 year ago

in the getQuery function I print out the $this->getLivewire(). Is there any way to get filters from this?

Screen Shot 2023-09-01 at 1 58 10 PM
pxlrbt commented 1 year ago

->tableFilters should be what you are looking for. Depending on your version there should also be methods to get the table query.

Umar-Farooq-Shafi commented 1 year ago

$this->getLivewire()->tableFilters giving me null.

Screen Shot 2023-09-01 at 2 27 05 PM
Umar-Farooq-Shafi commented 1 year ago

I'm using Filament v3

Umar-Farooq-Shafi commented 1 year ago

Solve by using cache.