1. Go to this page and download the library: Download smallerid/filament-exports library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
FilamentExportBulkAction::make('export')
->fileName('My File') // Default file name
->timeFormat('m y d') // Default time format for naming exports
->disablePdf() // Disable PDF format for download
->disableXlsx() // Disable XLSX format for download
->disableCsv() // Disable CSV format for download
->defaultFormat('pdf') // xlsx, csv, docx or pdf
->defaultPageOrientation('landscape') // Page orientation for pdf files. portrait or landscape
->directDownload() // Download directly without showing modal
->disableAdditionalColumns() // Disable additional columns input
->disableFilterColumns() // Disable filter columns input
->disableFileName() // Disable file name input
->disableFileNamePrefix() // Disable file name prefix
->disablePreview() // Disable export preview
->disableTableColumns() // Disable table columns in the export
->withHiddenColumns() //Show the columns which are toggled hidden
->fileNameFieldLabel('File Name') // Label for file name input
->formatFieldLabel('Format') // Label for format input
->pageOrientationFieldLabel('Page Orientation') // Label for page orientation input
->filterColumnsFieldLabel('filter columns') // Label for filter columns input
->additionalColumnsFieldLabel('Additional Columns') // Label for additional columns input
->additionalColumnsTitleFieldLabel('Title') // Label for additional columns' title input
->additionalColumnsDefaultValueFieldLabel('Default Value') // Label for additional columns' default value input
->additionalColumnsAddButtonLabel('Add Column') // Label for additional columns' add button
->withColumns([TextColumn::make('additionalModelColumn')]) // Export additional model columns that aren't visible in the table results
->csvDelimiter(',') // Delimiter for csv files
->modifyExcelWriter(fn (SimpleExcelWriter $writer) => $writer->nameCurrentSheet('Sheet')) // Modify SimpleExcelWriter before download
->modifyPdfWriter(fn (\Barryvdh\DomPDF\PDF|\Barryvdh\Snappy\PdfWrapper $writer) => $writer->setPaper('a4', 'landscape')) // Modify DomPdf or Snappy writer before download
->formatStates([
'name' => fn (?Model $record) => strtoupper($record->name),
]) // Manually format states for a specific column