Exporting CSV, XLSX & PDF
Export the current filtered/sorted grid to CSV, XLSX, or PDF from the toolbar - and import rows back in from a CSV file.
Exporting the current grid state
Every grid's toolbar has an export/import menu with CSV, XLSX, and PDF options. Exporting reuses whatever the grid is currently showing - any active simple search, per-column search, Advanced Search conditions, filter tab, and sort order - not an unfiltered dump of the raw table. Search and sort first, then export, to get exactly the rows and order a visitor is looking at.
No PHP call is required to enable exporting - it's built into every grid automatically, for both ->table() and ->query() report-mode grids alike.
$xcrud = Xcrud::get_instance();
$xcrud->table('customers');
$xcrud->route('csv-download');
$xcrud->columns('customerNumber,customerName,contactFirstName,contactLastName,city,country,creditLimit');
$xcrud->change_type('creditLimit', 'price', '2', ['prefix' => '$']);
$xcrud->order_by('customerName', 'asc');
Only the columns currently visible in ->columns() (and not toggled off via the More Options column-visibility menu) are included in the export.
Row limits
XcrudConfig::$exportRowLimit caps how many rows a single export can contain:
| Setting | Type | Default | Description |
|---|---|---|---|
$exportRowLimit | int | 50000 | Maximum rows a single CSV/XLSX/PDF export will include, applied server-side regardless of the current filter's actual result count. |
CSV import
The same toolbar menu also supports importing - uploading a CSV file to bulk-create or bulk-update rows in the underlying table. Import is only available on a real ->table()-backed grid, not a read-only ->query() report.
| Setting | Type | Default | Description |
|---|---|---|---|
$importRowLimit | int | 5000 | Maximum rows a single CSV import request will insert or update - kept far lower than $exportRowLimit, since a bulk write is a heavier, riskier operation than a bulk read. |
See the XcrudConfig Reference for every other setting.