zhortein/datatable-bundle provides server-side exports in CSV and XLSX formats. These exports are generated server-side and do not rely on client-side plugins.
Currently implemented:
- Formats: CSV (native), XLSX (via optional OpenSpout dependency).
- Modes:
current: Exports only the currently visible page.full: Exports the entire filtered dataset (pagination disabled).
- Features: Toolbar export dropdown, custom export URLs, column visibility awareness.
Not implemented yet:
- Asynchronous/Background exports.
- Export progress UI.
- Export size limits configuration.
- Streamed Doctrine iterators (currently loads full result set into memory).
CSV is the default dependency-free format. It uses PHP built-ins for escaping and UTF-8 encoding.
XLSX support requires the openspout/openspout library.
composer require openspout/openspoutTo enable XLSX in the UI, update your zhortein_datatable call:
{{ zhortein_datatable('users', {
exportFormats: ['csv', 'xlsx']
}) }}Exports respect the current state of the datatable:
- Search queries
- Simple filters
- Advanced filter expressions
- Sorting
- Runtime column visibility
| Mode | Behavior |
|---|---|
current |
Exports the rows of the current page. |
full |
Exports all rows matching the current filters, ignoring pagination. |
Note: "Full" export means the filtered dataset, not the raw database table.
The current implementation is synchronous. The data is loaded into memory before being written to the response.
- Encourage users to apply filters before performing a "full" export.
- Keep the number of exported columns to a minimum.
- Be cautious with "full" exports on datasets with more than 10,000 rows.
- For millions of rows, synchronous export is not recommended and may hit PHP memory or execution time limits.
Exports are enabled by default. You can disable them or provide custom URLs:
{{ zhortein_datatable('users', {
export: false, // Disable all exports
exportUrl: path('custom_export'), // Custom URL for default format (CSV)
exportUrls: {
csv: path('custom_csv'),
xlsx: path('custom_xlsx')
}
}) }}Exports respect runtime column visibility. Columns hidden in the UI will not be included in the exported file.
The export endpoint does not include a built-in authorization layer beyond the route protection. Host applications should protect the zhortein_datatable_export route according to their security requirements.