explaingit

spartnernl/laravel-excel

12,655PHPAudience · developerComplexity · 2/5LicenseSetup · moderate

TLDR

PHP package for Laravel that makes reading and writing Excel and CSV files straightforward, with built-in support for large datasets via chunking and background queue processing.

Mindmap

mindmap
  root((laravel-excel))
    Exports
      Database to Excel
      Chunked for memory
      Queued background
      Blade table export
    Imports
      Excel to models
      CSV reading
      Queued background
    Tech Stack
      PHP
      Laravel
      PhpSpreadsheet
    Audience
      PHP developers
      Laravel teams
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Export database records to a downloadable Excel file that users can save from a Laravel web app.

USE CASE 2

Import uploaded CSV or Excel files and load the rows into database models, processing large files in the background without timeouts.

USE CASE 3

Generate a styled Excel report by converting an existing Laravel Blade HTML table directly to xlsx format.

USE CASE 4

Queue a large export job so it runs asynchronously and the user keeps using the app while the file is prepared.

Tech stack

PHPLaravelPhpSpreadsheet

Getting it running

Difficulty · moderate Time to first run · 30min

Requires an existing Laravel project with Composer, install via composer require and publish the config.

MIT license, use freely for any purpose including commercial projects, as long as you keep the copyright notice.

In plain English

Laravel Excel is a PHP package that makes it straightforward to read and write Excel and CSV files inside a Laravel web application. Laravel is a popular PHP framework for building web applications, and this package slots into it cleanly, following Laravel's conventions so it feels like a natural part of the framework rather than an external add-on. For exports, the package can take a collection of database records and write them directly to an Excel file that users can download. It handles large datasets by automatically splitting the work into smaller pieces (called chunks) so the server does not run out of memory when dealing with tens of thousands of rows. Exports can also be pushed to a background queue, meaning the file is generated asynchronously while the user continues using the application, rather than waiting for a potentially slow operation to complete. The README also mentions the ability to export a styled HTML table (created with Laravel's Blade template system) directly to Excel, for cases where layout matters. For imports, the package reads Excel or CSV files and loads the data into database models. Like exports, large files can be read in chunks and processed via queued jobs running in the background, which prevents timeouts on big imports. The package is built on top of PhpSpreadsheet, an underlying PHP library that handles the actual Excel file format. Laravel Excel acts as a wrapper that makes PhpSpreadsheet fit naturally into the Laravel way of doing things. It is free to use under the MIT license. The authors describe it as "Postcardware," meaning they do not require payment but ask that anyone who uses it in a production application send a physical postcard to their office in the Netherlands. The package is maintained by Spartner, a Dutch software development company. Full documentation is hosted on a separate site rather than in the README itself.

Copy-paste prompts

Prompt 1
Using Laravel Excel, write an export class that fetches all rows from the orders table and lets users download them as an Excel file, with chunking enabled so the server does not run out of memory.
Prompt 2
I have a Laravel app where users upload CSV files with product data. Write an import class that reads the file in chunks and upserts each row into the products table.
Prompt 3
Show me how to push a Laravel Excel export job onto the queue so the file is generated in the background and the user gets a download link by email when it is ready.
Prompt 4
I want to export a Laravel Blade view that contains an HTML table as a styled Excel file. Show me how to set up a view export with Laravel Excel.
Prompt 5
How do I add custom column headings and format a date column as DD-MM-YYYY in a Laravel Excel export class?
Open on GitHub → Explain another repo

← spartnernl on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.