- How do I export Eloquent models to Excel in Laravel using FastExcel?
- Use the `FastExcel` class with your Eloquent collection. For example, `(new FastExcel(User::all()))->export('users.xlsx')` generates an XLSX file. You can also customize columns with a callback for dynamic formatting.
- Does FastExcel support CSV imports with custom delimiters or encodings?
- Yes, configure CSV settings via `configureCsv()` before importing. For example, `(new FastExcel)->configureCsv(';', '#', 'gbk')->import('file.csv')` handles semicolon-delimited GBK-encoded files.
- Can I directly download an Excel file from a Laravel controller?
- Absolutely. Use `download()` to stream the file to the browser: `return (new FastExcel(User::all()))->download('report.xlsx');`. This works seamlessly with Laravel’s HTTP responses.
- What Laravel and PHP versions does FastExcel support?
- FastExcel requires **PHP 8.0+** and **Laravel 9+**. It leverages Spout v3, so ensure your server and CI/CD pipelines meet these requirements. Older versions (PHP 7.1) are unsupported.
- How does FastExcel handle large datasets (e.g., 100K+ rows)?
- FastExcel uses Spout’s streaming architecture to avoid memory overload. For very large exports, queue the job with Laravel Queues to prevent timeouts or use chunking for database inserts.
- Can I map imported rows directly to database inserts?
- Yes. Pass a callback to `import()` to transform rows into database records. Example: `(new FastExcel)->import('users.xlsx', fn($row) => User::create($row))` inserts each row as a new model.
- Does FastExcel work with Laravel Nova for custom exports?
- Yes, FastExcel integrates easily with Nova. Add export buttons to Nova resources by returning a `FastExcel` instance from a custom action, enabling admin users to download Excel files directly.
- What are the alternatives to FastExcel for Laravel Excel exports?
- Compare **Laravel Excel** (feature-rich, supports templates) or **PhpSpreadsheet** (advanced Excel features like charts). FastExcel prioritizes speed and simplicity for bulk data operations.
- How do I handle file uploads larger than 100MB in FastExcel?
- FastExcel processes files in streams, but for very large uploads, preprocess files client-side (e.g., chunk uploads) or use Laravel’s `request()->file()->getRealPath()` with caution to avoid memory issues.
- Is FastExcel suitable for real-time Excel updates (e.g., WebSocket-driven)?
- No, FastExcel is optimized for batch processing, not real-time streaming. For live updates, consider WebSocket libraries paired with a separate API endpoint for incremental data pushes.