Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Fast Excel Laravel Package

rap2hpoutre/fast-excel

Fast Excel import/export for Laravel, powered by Spout. Export Eloquent models, queries, or collections to xlsx, ods, or csv with a simple API, customize columns via callbacks, and handle large files efficiently. Benchmark-tested for speed.

View on GitHub
Deep Wiki
Context7

Fast Excel is a Laravel package for fast, memory-efficient Excel import and export powered by Spout. It exports Eloquent models, queries, and collections to xlsx, ods, and csv files, returning the absolute path to the written file. A callback lets you shape each row with custom column names and computed values, keeping exports simple and readable.

  • Export models, queries, or collections in one line
  • Supports xlsx, ods, and csv formats
  • Callback-based column mapping and formatting
  • hideColumnsPrefixedWith() for callback-only data
  • Fast, low-memory streaming via Spout
Frequently asked questions about Fast Excel
How do I install rap2hpoutre/fast-excel in a Laravel app?
Install the package with Composer by running composer require rap2hpoutre/fast-excel. Laravel's package discovery registers the service provider and FastExcel facade automatically. You can then use the FastExcel class, the FastExcel facade, or the fastexcel() helper without publishing configuration.
Which Laravel and PHP versions does fast-excel support?
Fast Excel is optimized for modern Laravel applications and requires PHP 8.0 or newer. It integrates with Laravel 9+ and uses Eloquent, Collections, and the service container. Older PHP 7.x projects should stay on legacy packages or upgrade before adopting it.
How does fast-excel handle very large exports without using too much memory?
It is built on Spout v3, which streams rows instead of loading the entire workbook into memory. The chunked export API with yield lets you process large datasets in batches. This makes exports of 1M+ rows feasible with a small memory footprint, but you should still benchmark and monitor memory in staging.
How do I export an Eloquent model or collection to Excel or CSV?
Pass a model query result, Eloquent collection, or Laravel collection into the FastExcel constructor, then call export with a file path. For example, (new FastExcel(User::all()))->export('users.xlsx') writes an XLSX file. The same API supports ODS and CSV by changing the file extension. From a controller you can return the download response using the package's download method.
Can I choose which columns are exported and rename their headers?
Yes, pass a callback as the second argument to export and return an associative array of column names to values. For example, return ['Email' => $user->email, 'First Name' => $user->firstname]. You can also hide helper columns with hideColumnsPrefixedWith so callback-only values do not appear in the file.
How do I import an Excel or CSV file and insert rows into the database?
Call import on a FastExcel instance to read the file into a Laravel collection. You can then transform rows or use the create method to insert them directly into a model's table. This import plus create pattern is useful for bulk seeding and simple ETL workflows.
Can fast-excel export CSV files with custom delimiters or encodings?
Yes, CSV output can be configured with options such as delimiters and encodings to support localized deployments. The assessment notes that locale-specific encodings like gbk should be validated in QA. Provide sensible fallback defaults for environments with different CSV expectations.
How is fast-excel different from Laravel Excel or PhpSpreadsheet?
Fast Excel focuses on speed and low memory use through Spout streaming, while Laravel Excel and PhpSpreadsheet offer richer Excel features. Basic exports and imports can often be replaced with fewer than 5 percent code changes. Choose Fast Excel for simple high-volume files and Laravel Excel when you need advanced formatting or templates.
Does fast-excel support multi-sheet workbooks, charts, formulas, or merged cells?
No, it is intentionally limited to straightforward single-sheet imports and exports. It does not provide charts, formulas, merged cells, or complex Excel templates. Multi-sheet relationships require manual mapping, so use Laravel Excel if those features are mandatory.
Is rap2hpoutre/fast-excel actively maintained and safe for production?
The package is MIT licensed and actively developed, with Spout v3 as its underlying engine. It is production-ready for simple, high-volume Excel and CSV operations when you pin versions with composer.lock and test upgrades. Monitor Spout major releases and benchmark performance against your baseline after integration.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
thomas-0816/doctrine-dbal-duckdb
moyisoft/laravel-admin
oxygen/mod-pages
oxygen/mod-import-export
oxygen/mod-media
ksoft/laravel-contentbuilderjs
ourgoldpackages/exchange
mikkimike/laravel-exchange1c
wandesnet/mercadopago-laravel
tsfcorp/email
larafony/core
laravel-enso/currencies
tartan/laravel-online-payment
gam/laravel-sat-catalogs
cloudcreativity/laravel-stripe
abdulelahragih/querybuilder
wedevbr/celcoin-laravel
surazdott/nepali-date
devsquad-cockpit/laravel
coding-socks/laravel-upload-handler