jeffersongoncalves/filament-action-export

Export Filament tables to CSV, XLSX and PDF with preview and print support.

Maintainers

Package info

github.com/jeffersongoncalves/filament-action-export

pkg:composer/jeffersongoncalves/filament-action-export

Fund package maintenance!

jeffersongoncalves

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v3.1.0 2026-03-06 02:30 UTC

This package is auto-updated.

Last update: 2026-03-06 02:30:51 UTC


README

Filament Action Export

Filament Action Export

Tests Latest Version on Packagist Total Downloads License

Export Filament tables to CSV, XLSX and PDF with preview and print support.

Version Compatibility

Package Filament PHP Laravel Livewire
^1.0 ^3.0 ^8.1 ^10.0 | ^11.0 ^3.0
^2.0 ^4.0 ^8.2 ^11.0 ^3.0
^3.0 ^5.0 ^8.2 ^11.28 ^4.0

This is the 3.x branch, compatible with Filament v5 (Livewire v4).

Installation

composer require jeffersongoncalves/filament-action-export "^3.0"

Publish config (optional)

php artisan vendor:publish --tag=filament-action-export-config

Publish views (optional)

php artisan vendor:publish --tag=filament-action-export-views

Publish translations (optional)

php artisan vendor:publish --tag=filament-action-export-lang

Usage

As Bulk Action

use JeffersonGoncalves\FilamentExportAction\Actions\ExportAction;
use JeffersonGoncalves\FilamentExportAction\Enums\ExportFormat;
use JeffersonGoncalves\FilamentExportAction\ValueObjects\AdditionalColumn;

public function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('name'),
            TextColumn::make('email'),
        ])
        ->toolbarActions([
            Actions\BulkActionGroup::make([
                ExportAction::make('export')
                    ->formats([ExportFormat::Csv, ExportFormat::Xlsx, ExportFormat::Pdf])
                    ->defaultFormat(ExportFormat::Xlsx)
                    ->userCanSelectColumns()
                    ->excludeColumns(['password', 'remember_token'])
                    ->additionalColumns([
                        AdditionalColumn::make('exported_at')
                            ->defaultValue(now()->format('d/m/Y')),
                    ])
                    ->extraViewData(['companyName' => 'Acme Corp']),
            ]),
        ]);
}

As Header Action

use JeffersonGoncalves\FilamentExportAction\Actions\ExportAction;
use JeffersonGoncalves\FilamentExportAction\Enums\ExportFormat;

public function table(Table $table): Table
{
    return $table
        ->columns([
            TextColumn::make('name'),
            TextColumn::make('email'),
        ])
        ->headerActions([
            ExportAction::make('export')
                ->formats([ExportFormat::Csv, ExportFormat::Xlsx, ExportFormat::Pdf])
                ->defaultFormat(ExportFormat::Xlsx)
                ->withFilters()
                ->withSearch()
                ->withSort()
                ->snappy()
                ->extraViewData(['companyName' => 'Acme Corp']),
        ]);
}

Configuration Options

Formats

->formats([ExportFormat::Csv, ExportFormat::Xlsx, ExportFormat::Pdf])
->defaultFormat(ExportFormat::Xlsx)

File Name

// Custom file name
->fileName('my-report')

// File name prefix (prepended to the name)
->fileNamePrefix('users')

// Custom time format for the filename suffix
->timeFormat('d_m_Y-H_i')

// Disable file name input in the modal
->disableFileName()

// Full control via closure
->fileNameUsing(fn ($action) => 'custom-' . now()->format('Y-m-d'))

Direct Download

Skip the modal form and download immediately with default settings:

->directDownload()

Columns

// Use specific columns
->columns(['id', 'name', 'email'])

// Exclude columns
->excludeColumns(['password', 'remember_token'])

// Let users choose columns in the modal
->userCanSelectColumns()

// Include hidden (toggled) columns in the export
->withHiddenColumns()

Additional Columns

->additionalColumns([
    AdditionalColumn::make('exported_at')
        ->label('Exported At')
        ->defaultValue(now()->format('d/m/Y')),
    AdditionalColumn::make('notes')
        ->label('Notes')
        ->defaultValue('N/A'),
])

Format States

Custom formatting for column values:

->formatStates([
    'name' => fn ($value, $record) => strtoupper($value),
    'created_at' => fn ($value) => Carbon::parse($value)->format('d/m/Y'),
    'status' => fn ($value) => match ($value) {
        'active' => 'Active',
        'inactive' => 'Inactive',
        default => $value,
    },
])

CSV Delimiter

->csvDelimiter(';')  // Default: ','

PDF Driver

By default, the package uses barryvdh/laravel-dompdf. You can switch to barryvdh/laravel-snappy:

composer require barryvdh/laravel-snappy
// Use Snappy
->snappy()

// Or set driver explicitly
->pdfDriver('snappy')

// Custom PDF options
->pdfOptions(['paper' => 'a4', 'orientation' => 'landscape'])

Writer Callbacks

Customize the Excel or PDF writer before the file is generated:

// Modify the SimpleExcelWriter (CSV/XLSX)
->modifyExcelWriter(fn (SimpleExcelWriter $writer) => $writer)

// Modify the PDF instance (DomPDF or Snappy)
->modifyPdfWriter(fn ($pdf) => $pdf->setWarnings(false))

Extra View Data

// Static array
->extraViewData(['companyName' => 'Acme Corp'])

// Dynamic closure
->extraViewData(fn ($action) => [
    'recordCount' => $action->getRecords()->count(),
])

Header Action Specific Options

->withFilters()   // Apply active table filters to export
->withSearch()    // Apply active search to export
->withSort()      // Apply active sort to export

Preview Component

<livewire:filament-action-export.export-preview
    :records="$records"
    :columns="$columns"
    :extra-data="$extraData"
/>

Config File

// config/filament-action-export.php

return [
    'pdf_driver'      => env('FILAMENT_EXPORT_PDF_DRIVER', 'dompdf'),
    'default_format'  => env('FILAMENT_EXPORT_DEFAULT_FORMAT', 'xlsx'),
    'formats'         => ['csv', 'xlsx', 'pdf'],
    'csv_delimiter'   => ',',
    'chunk_size'      => 1000,
    'pdf_options'     => [
        'paper'       => 'a4',
        'orientation' => 'portrait',
    ],
    'preview_enabled' => true,
    'print_enabled'   => true,
];

Customizing Views

After publishing the views, you can customize them:

  • resources/views/vendor/filament-action-export/pdf.blade.php - PDF template
  • resources/views/vendor/filament-action-export/print.blade.php - Print template
  • resources/views/vendor/filament-action-export/components/table-view.blade.php - Preview table

Translations

The package includes translations for: English, Brazilian Portuguese, Spanish, French, German, Italian, Dutch, Arabic, and Turkish.

After publishing, add your own translations in lang/vendor/filament-action-export/.

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security-related issues, please email security@jeffersongoncalves.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.