PHP code example of wali / filament-word-export

1. Go to this page and download the library: Download wali/filament-word-export 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/ */

    

wali / filament-word-export example snippets


use Wali\FilamentWordExport\Actions\ExportToWordAction;

public function table(Table $table): Table
{
    return $table
        ->columns([
            // Your table columns
        ])
        ->bulkActions([
            ExportToWordAction::make(),
        ]);
}

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'),
        ]);
}

ExportToWordAction::make()
    ->templateOverrides([
        'header.style.size' => 12,
        'header.style.color' => '0066CC',
        'footer.style.italic' => true,
        'footer.page_number_alignment' => 'left',
    ])

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',
    ],
];
bash
php artisan vendor:publish --tag="filament-word-export-config"