When exporting in Excel, the table comes blank Can you help?
"When I attempt to download an Excel file using this method, the downloaded file is empty, and the data from the selected portion does not appear in the Excel table."
When I use it as shown above, it downloads the data for the entire table instead of the intended selection
I simply want the content of the data to be downloaded when I press the export button next to it. https://filamentphp.com/plugins/pxlrbt-excel#usage
22 Replies
I beleive you are using a table action opposed to a header action. So therefore you need to select the records to export
"I also tried this process by selecting it, but once again, the Excel table appears to be empty."
ExportAction::make()->exports([
ExcelExport::make()->withWriterType(\Maatwebsite\Excel\Excel::XLSX),
])
Intresting, can you check which class you are extending for the export button?
and is this V3 or V2
V3
@Dennis Koch thoughts? #pxlrbt-excel
You didn't specify any columns that why it doesn't export any. Please check the docs. You can use
->fromTable()
, ->formRecord()
, ->withColumns()
, ...Actually, the problem is that I have tried these of course, I select a single data to download, but it downloads all the records. for example
That's because youn are then using the header action, opposed to a bulk action I suspect?
The bulkActions part works correctly and gives the result I want, but the action part does not work the same way.
The action part is the table action, so it's designed to export the whole table.
I don't think there's any way I can get this one.
You want the Table Action Button to respect the same process as BulkAction, right?
Yes
You will need to review https://filamentphp.com/plugins/pxlrbt-excel#modify-the-query and look to include a where, the id's are in$this->table->selectedId's or similar.
I am trying to access the clicked record but I have not been successful at this point
->modifyQueryUsing(fn (Payment $record) => $record->where('id',$record->id))
->modifyQueryUsing(fn (Payment $record) => $record->where('id',$record->id))
use $this->table ?
Not working $this->table
Then I am unsure,
I don’t think you can access the Livewire component from that closure.
I don’t understand why you are trying to replicate the same behavior as a BulkAction instead of using the bulk action
I know why, it's to reduce a single click, which does make sense in a high use exporting scenario.
You can have ungrouped BulkActions in v3