Table of contents
Exports
Enable exports
Use the WithExport trait in the table component:
use RealZone22\PenguTables\Traits\WithExport;
class Users extends PenguTable
{
use WithExport;
}
Configure the available formats with Options:
use RealZone22\PenguTables\Table\ExportTypes;
protected function setupOptions(): Options
{
return parent::setupOptions()->withExport(
true,
ExportTypes::CSV_ALL,
ExportTypes::CSV_SELECTED,
ExportTypes::XLSX_ALL,
ExportTypes::XLSX_SELECTED,
);
}
Export types
ExportTypes::CSV_ALLExportTypes::CSV_SELECTEDExportTypes::XLSX_ALLExportTypes::XLSX_SELECTED
If export is disabled, pass false:
->withExport(false)
Export columns
The export uses the table column definitions. Exclude a column with:
Column::make('Actions', null)
->hideInExport();
The displayed column label is used as the export header. Formatted values are converted to plain text before they are written.
Export all rows
“All” exports use the base query with the current search and filters. They are processed in chunks, so the complete result set does not need to be loaded into memory at once.
Export selected rows
“Selected” exports use the current selection state. This includes the large-table Select-All mode and its explicitly deselected rows. Selected exports are also processed through the chunked query exporter.
Filename
Set the export filename prefix in config/pengutables.php:
'export_filename' => 'users_'.now()->format('Ymd_Hi'),
The package appends .csv or .xlsx.