wali / filament-word-export
A powerful Filament plugin for exporting table data to Word documents with customizable headers, footers, and styling
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 2
pkg:composer/wali/filament-word-export
Requires
- php: ^8.3
- filament/filament: ^4.0
- illuminate/support: ^11.0|^12.0
- phpoffice/phpword: ^1.4.0
- spatie/laravel-package-tools: ^1.14
Requires (Dev)
- laravel/pint: ^1.25
- rector/rector: ^2.1
- dev-main
- v1.2.0
- v1.1.0
- v1.0.0
- dev-dependabot/composer/rector/rector-2.2.5
- dev-dependabot/composer/filament/filament-4.1.10
- dev-dependabot/composer/filament/filament-4.1.9
- dev-dependabot/composer/rector/rector-2.2.3
- dev-feat/custom-temlpate
- dev-enhancement/filament-3x-4x-compatibility
- dev-feature/stage1-custom-headers-footers
This package is auto-updated.
Last update: 2025-10-27 10:53:48 UTC
README
A Filament plugin for exporting table data to Microsoft Word (DOCX) format.
Requirements
- PHP 8.3+
- Laravel 11.x or 12.x
- Filament 3.x or 4.x
Installation
You can install the package via composer:
composer require wali/filament-word-export
Usage
Basic Usage
Add the export action to your Filament table:
use Wali\FilamentWordExport\Actions\ExportToWordAction; public function table(Table $table): Table { return $table ->columns([ // Your table columns ]) ->bulkActions([ ExportToWordAction::make(), ]); }
Customizing Headers and Footers
You can customize headers and footers per action:
use Wali\FilamentWordExport\Actions\ExportToWordAction; public function table(Table $table): Table { return $table ->bulkActions([ // Custom header and footer text ExportToWordAction::make() ->headerText('My Company Report') ->footerText('Confidential Document') ->withPageNumbers(), // Disable headers/footers entirely ExportToWordAction::make('export-clean') ->label('Export (Clean)') ->withoutHeader() ->withoutFooter(), // Custom filename ExportToWordAction::make('export-custom') ->filename('custom-report-' . now()->format('Y-m-d') . '.docx'), ]); }
Advanced Customization
For more advanced customization, you can use template overrides:
ExportToWordAction::make() ->templateOverrides([ 'header.style.size' => 12, 'header.style.color' => '0066CC', 'footer.style.italic' => true, 'footer.page_number_alignment' => 'left', ])
Configuration
Publish the configuration file:
php artisan vendor:publish --tag="filament-word-export-config"
Configuration Options
The configuration file allows you to set default values for headers and footers:
return [ 'header' => [ 'enabled' => true, 'text' => 'Generated by Filament Word Export Plugin', 'style' => [ 'italic' => true, 'size' => 10, 'color' => '000000', 'alignment' => 'center', ], 'logo' => [ 'enabled' => false, 'path' => null, // e.g., 'logos/company-logo.png' 'width' => 100, 'height' => 50, 'alignment' => 'left', ], ], 'footer' => [ 'enabled' => true, 'text' => 'Generated via Filament Word Export Plugin', 'style' => [ 'size' => 9, 'color' => '999999', 'alignment' => 'center', ], 'show_page_numbers' => true, 'page_number_format' => 'Page {PAGE} of {NUMPAGES}', 'page_number_alignment' => 'right', ], ];
Development
This project uses Laravel Pint for code formatting and Rector for automated refactoring.
Code Formatting with Pint
# Check code style composer lint:test # Fix code style issues composer lint # Fix only dirty files (git) composer lint:dirty
Code Refactoring with Rector
# Preview changes (dry run) composer refactor:dry # Apply refactoring changes composer refactor
Combined Commands
# Check formatting and preview refactoring composer format # Apply both formatting and refactoring composer fix
Manual Tool Usage
You can also run the tools directly:
# Pint ./vendor/bin/pint ./vendor/bin/pint --test ./vendor/bin/pint --dirty # Rector ./vendor/bin/rector process ./vendor/bin/rector process --dry-run
Configuration Files
pint.json- Laravel Pint configurationrector.php- Rector configurationconfig/filament-word-export.php- Plugin configuration
License
The MIT License (MIT). Please see License File for more information.