inlayphp/tables-xlsx is the optional first-party PhpSpreadsheet adapter for
inlayphp/tables.
It adds a real .xlsx download while keeping the core table package small and
dependency-free.
- PHP 8.3 or newer
- Laravel 12
- The PHP extensions required by PhpSpreadsheet
composer require inlayphp/tables-xlsxLaravel loads the package automatically; no config or registration is needed.
Register the driver on a header action:
use Inlay\Tables\Actions\ExportAction;
use Inlay\Tables\Exports\ExportColumn;
use Inlay\Tables\Xlsx\PhpSpreadsheetExportDriver;
ExportAction::make('export-xlsx')
->label('Excel')
->format('xlsx')
->driver(PhpSpreadsheetExportDriver::class)
->filename('users.xlsx')
->columns([
ExportColumn::make('name')->label('Name'),
ExportColumn::make('email')->label('Email'),
]);Put the same action in bulkActions() to export selected rows or all rows
matching the current table query:
->bulkActions([
ExportAction::make('export-selected')
->label('Excel')
->format('xlsx')
->driver(PhpSpreadsheetExportDriver::class)
->filename('selected-users.xlsx')
->maximumRows(10_000),
])The table automatically changes this action to its selection-aware POST
transport. The server reconstructs the authorized query, reapplies declared
search, filters, and sorting, validates the selection, and enforces the export
row limit before the workbook is written. Queueing remains application-owned
through ExportAction::queueUsing() so applications can choose storage,
retention, signed URLs, notifications, and worker authorization.
If columns() is omitted, every declared table column is exported. Table
presentation callbacks and ExportColumn::stateUsing() run before values are
written. Numeric and boolean values preserve their spreadsheet types; nulls
become empty cells; dates use ISO-8601; arrays and objects use JSON. Formula-like
strings are written as literal text to prevent spreadsheet formula injection.
The first row is bold, lightly shaded, frozen, and has an autofilter. Columns
are sized from their content and the safe filename validation remains owned by
ExportAction, so user input cannot choose a path or unsafe response header.
CSV remains available without third-party dependencies. XLSX is an adapter, so
applications that do not need spreadsheet workbooks do not install
PhpSpreadsheet or its extension requirements. Community packages can implement
the same Inlay\Tables\Contracts\ExportDriver contract for PDF, ODS, or other
formats.
Exercise PhpSpreadsheetExportDriver::response() with a declared Table and
read the returned attachment with PhpSpreadsheet. Keep authorization and query
construction in the table definition; this package should remain a serializer
of the already-authorized ExportData boundary.