rap2hpoutre/fast-excel
Fast, memory-efficient Excel/CSV/ODS import/export for Laravel using Spout. Export Eloquent models or collections to XLSX/CSV/ODS with custom column mapping, and download from controllers. Import files to collections, configure CSV options, or transform rows into DB inserts.
FastExcel::) and global helper (fastexcel()) reduce cognitive overhead, accelerating developer adoption.yield) enables custom event integration (e.g., logging, validation) via middleware or decorators.// Before (Laravel Excel)
Excel::download(new UserExport, 'users.xlsx');
// After (FastExcel)
return (new FastExcel(User::all()))->download('users.xlsx');
download() method integrates with Laravel’s response system, supporting file downloads, API responses, and queued exports (via Laravel Queues).import() + create() pattern enables direct database seeding from Excel/CSV, simplifying ETL workflows for bulk operations.with() methods).| Risk | Mitigation Strategy |
|---|---|
| Breaking Changes | Test thoroughly with PHP 8+ and Laravel 9+; use composer.lock to pin versions. |
| Memory Leaks in Large Exports | Use chunked exports (yield) and monitor memory usage in staging. |
| CSV Encoding Issues | Validate locale-specific encodings (e.g., gbk) in QA; provide fallback defaults. |
| Multi-Sheet Complexity | Document workarounds for multi-sheet use cases; consider Laravel Excel for advanced needs. |
| Dependency Updates | Monitor Spout v3 updates; test backward compatibility with major releases. |
| Performance Regression | Benchmark against baseline (e.g., Laravel Excel) post-integration. |
yield) are mandatory.| Step | Action | Tools/Notes |
|---|---|---|
| 1. Assessment | Audit current Excel operations (Laravel Excel/PhpSpreadsheet) for format/complexity. | Use static analysis to identify dependencies. |
| 2. Pilot | Replace 1–2 high-volume exports (e.g., user reports, financial data) with FastExcel. | Compare speed/memory vs. baseline. |
| 3. Facade Adoption | Add FastExcel facade to config/app.php for global access. |
Reduces boilerplate in controllers. |
| 4. Chunked Exports | Implement yield-based exports for >10K rows. |
Test with load testing (e.g., Artisan commands). |
| 5. CSV Customization | Configure delimiters/encodings for global deployments. | Validate with edge-case CSVs. |
| 6. Import Workflows | Replace manual CSV imports with FastExcel->import()->create(). |
Test data validation and error handling. |
| 7. Deprecation | Phase out Laravel Excel/PhpSpreadsheet for simple use cases. | Document migration guide for team. |
return (new FastExcel(Order::all()))->download('orders.xlsx');FastExcel->import()->create().FastExcel::import('users.csv')->each(fn($row) => User::create($row));yield) for >100K rows.fastexcel(usersGenerator())->export('large_file.xlsx');->headerStyle($boldStyle)->rowsStyle($colorStyle).composer.json post-validation.How can I help you explore Laravel packages today?