Skip to content

No results for

navigate open Esc close

Pro Component — This feature is part of the Aura UI Pro WithAuraDataTable trait.

Overview

WithAuraDataTable ships an export() method that streams the current result set — with the active search, filters and sort applied across all pages — as a CSV download. It exports the currently visible columns (excluding the actions column), uses each column's formatted value (date/number/format closures, never HTML render closures), chunks rows so large tables export without exhausting memory, and writes a UTF-8 BOM so Microsoft Excel opens accented characters correctly.

Basic Usage

Add an export button to your table view that calls the export action:

<x-aura::button wire:click="export" icon="download">
    Export CSV
</x-aura::button>

That's it — no extra code is required in the component. The download reflects whatever the user is currently looking at (search term, filters, sort).

Customising the file name

Override exportFileName() on your component:

public function exportFileName(): string
{
    return 'users-'.now()->format('Y-m-d').'.csv';
}

Choosing the exported columns

By default the export contains the currently visible columns. Override getExportColumns() to export a fixed set regardless of column visibility:

use BlueStarSystem\AuraUIPro\DataTable\Column;

public function getExportColumns(): array
{
    return collect($this->columns())
        ->reject(fn (Column $c) => $c->isActions())
        ->all();
}

How values are formatted

Each cell uses Column::getValue(), so ->date(), ->number(), and ->format(fn ($v) => ...) are applied to the exported value. Nulls become empty strings, booleans become 1/0, dates become Y-m-d H:i:s, and arrays are JSON-encoded.

Programmatic use

You can build a CSV string directly with the underlying CsvExporter (useful in jobs or mailables):

use BlueStarSystem\AuraUIPro\DataTable\Exporters\CsvExporter;

$csv = (new CsvExporter($columns))->toString($rows);