Guide · Open source
How to use Laravel-Excel: exports, imports and queues
Updated · written with AI from the project's own documentation and checked against our catalogue data
Laravel-Excel is a PHP package for Laravel applications. It lets you export data from your app to Excel or CSV files and import spreadsheet rows into your models, without writing the low-level PhpSpreadsheet code yourself. This guide explains what it does, what you need before installing it, and how to approach exports, imports and background queues. After reading it, you will know whether the package fits your project and where to start.
Quick start
- 1Check versions. Compare your Laravel and PHP versions with the support table in the README and pick a supported package version.
- 2Install the package. Install Laravel-Excel into your Laravel project following the official documentation for your chosen version.
- 3Export a query. Pass a database query to the package to export results to Excel or CSV with automatic chunking.
- 4Export a collection or view. Export a Laravel collection, or a Blade view containing an HTML table, to a spreadsheet file.
- 5Import a spreadsheet. Read the uploaded workbook in chunks and insert rows into Eloquent models with batch inserts.
- 6Queue large jobs. Queue large exports or imports so each chunk runs in the background.
What Laravel-Excel does
Laravel-Excel is a simple wrapper around PhpSpreadsheet for Laravel exports and imports. You can export Laravel collections directly to an Excel or CSV document, and export database queries with automatic chunking for better performance.
On the import side, it reads workbooks and worksheets and inserts the data into Eloquent models, using chunk reading and batch inserts.
- Export collections to Excel or CSV
- Export database queries with automatic chunking
- Import workbooks and worksheets into Eloquent models
- Export a styled HTML table from a Blade view
Check the requirements and supported versions first
Laravel-Excel requires PHP and Laravel, and the exact versions depend on which package version you pick. The README's support table is the source of truth, so check it against your Laravel and PHP versions before you install.
As of the README, version 3.1 is CVE-only (no active support) and version 4.0 is the one receiving new features. Older versions are listed as unsupported. Do not adopt a version that does not match your stack.
- Laravel-Excel is a Laravel package, so it does not suit non-PHP projects
- Compare your Laravel and PHP versions with the support table in the README
- Use the documentation at docs.laravel-excel.com for the install steps for your version
Install the package with your package manager
The package is installed through a package manager in a Laravel project. The README's install command shown in the source is a git clone of the repository, which you can use to read the code or the source files. For normal use in an application, follow the install instructions in the official documentation for the version you chose.
Make sure you pick the version that matches your Laravel and PHP versions from the support table before installing.
git clone https://github.com/SpartnerNL/Laravel-ExcelExport query results and collections
The most common use is exporting database query results to Excel or CSV. You pass the query to the package and it handles chunking so large result sets are processed in pieces. For very large datasets, you can queue the export so it runs in the background.
You can also export a Laravel collection directly to an Excel or CSV document, which suits data you have already loaded and transformed in your code.
- Export a query for automatic chunking
- Export a collection to Excel or CSV
- Queue large exports to run in the background
Import spreadsheets into Eloquent models
To import data from users, Laravel-Excel reads the workbook in chunks and writes rows into Eloquent models using batch inserts. For large files you can queue every chunk, so the whole import runs in the background instead of blocking a web request.
Validate the uploaded file and the data it contains before you rely on it, so bad rows do not end up in your database.
- Read workbooks and worksheets in chunks
- Insert rows into Eloquent models with batch inserts
- Queue each chunk of a large file
Export a styled Blade view
If you need a custom layout in the spreadsheet, you can write an HTML table in a Blade view and export that view to Excel. This lets you reuse your existing view for the layout and styling of the file.
Understand the license before using it in production
Laravel-Excel is MIT licensed, but the README also describes it as Postcardware. If the package goes into your production environment, the authors ask you to send a postcard from your hometown. This is a request in the README, so check the license page at docs.laravel-excel.com whether it matters for your commercial project.
What people use it for
- Exporting database query results to Excel or CSV for reports
- Importing user-supplied spreadsheets into Eloquent models
- Running large exports or imports as background queue jobs
- Exporting a styled HTML table from a Blade view to a spreadsheet
Frequently asked questions
Is Laravel-Excel free to use?
The package is MIT licensed, so it is free to use. The README also says it is licensed as Postcardware: if it runs in your production environment, the authors ask you to send a postcard.
Which Laravel and PHP versions does Laravel-Excel support?
It depends on the package version. The README's support table lists version 3.1 as CVE-only and version 4.0 as receiving new features, with specific Laravel and PHP ranges for each. Check that table against your stack before installing.
Can Laravel-Excel export to CSV as well as Excel?
Yes. The README says collections can be exported directly to an Excel or CSV document.
Can I run large imports in the background?
Yes. The README says you can queue every chunk of a file so the entire import happens in the background.
What is Laravel-Excel built on?
It is a Laravel wrapper around PhpSpreadsheet, so developers do not have to handle the low-level spreadsheet code directly.
What are the alternatives to Laravel-Excel?
Comparable projects listed for this item are PhpSpreadsheet, Spatie Simple Excel and OpenSpout. PhpSpreadsheet is the library Laravel-Excel wraps, so it is the lower-level option.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Laravel-Excel suits Laravel developers who need to export query results or import spreadsheet data into Eloquent models, especially with queued background processing for large files. Pick a different tool if your project is not in PHP, if you need a standalone spreadsheet editor, or if you need a version still under active support, since the README marks 3.1 as CVE-only.
Install options & downloads