Fast Excel
Fast Excel stats
- Downloads
- 6.3M
- Stars
- 1,899
- Open Issues
- 74
- Forks
- 234
Fast Excel import/export for Laravel
FastExcel: Efficient Excel Import/Export for Laravel
FastExcel is a powerful Laravel package designed to simplify the import and export of Excel, CSV, and ODS files with minimal memory usage. It leverages the capabilities of Spout to provide fast operations, making it an ideal choice for projects where performance is critical.
Key Features
- Export Models and Collections: Easily export data from Eloquent models or Laravel collections to Excel, CSV, or ODS files.
- Selective Data Export: Customize exported data by specifying which columns to include.
- Download Support: Directly download files from a controller, simplifying the export process in web applications.
- Efficient Imports: Import files directly to Laravel collections, with support for complex configurations such as custom delimiters and encodings.
- Database Integration: Seamlessly create database entries from imported data.
- Multiple Sheets: Handle multiple sheets both in imports and exports, with support for named sheets.
- Memory Efficiency: Export large datasets with minimal memory footprint using generator functions.
- Styling Options: Customize the style of headers and rows when exporting data.
- Facade and Global Helper: Integrate FastExcel smoothly with Laravel’s facades and global helpers for more concise code.
Installation
Install FastExcel via Composer:
composer require rap2hpoutre/fast-excel
Usage Examples
Export a User model to an Excel file:
use Rap2hpoutre\FastExcel\FastExcel;use App\User; $users = User::all();(new FastExcel($users))->export('file.xlsx');
Import from an Excel file to a collection:
$collection = (new FastExcel)->import('file.xlsx');
Advanced Usage - Export with Chunking:
function usersGenerator() { foreach (User::cursor() as $user) { yield $user; }}(new FastExcel(usersGenerator()))->export('test.xlsx');
Conclusion
FastExcel is less feature-rich compared to Laravel Excel but excels in performance, making it suitable for simple tasks requiring high efficiency. It is a faster and memory-friendly alternative for straightforward Excel data handling in Laravel applications.
Tinkering @ beta.gouv.fr & fabrique.social.gouv.fr. Stodgy mixture of Rust, JS, PHP, Forth, SQL, GFA Basic, music and more.