Laravel Excel runs out of memory on a large export not because of your code but because of PhpSpreadsheet's architecture. Here is why chunking does not save you, and how streaming export through cursor() keeps memory flat.
You need Excel in PHP, and the very first search result is PhpSpreadsheet — universal, heavy, and not always the right fit. Let's sort out what kinds of Excel tasks actually exist (reading, writing, templates) and how to tell which one is yours, so you don't haul in a combine harvester where a screwdriver would do.
We had barely finished the post about 4.0 when 4.1 and 4.2 shipped. Here is what changed: Excel::open() now detects the format from the file signature and reads XLSX, XLS, and CSV in a single line — no more branching on the file extension.
FastExcelReader 4 reads the old XLS format (Excel 97–2003) through exactly the same methods you already use for XLSX — no second library, no branching in your code. withHeader() now accepts your own column names, and XLSX reading got about 1.5 times faster. A walkthrough of what version 4 brings.
PhpSpreadsheet burns hundreds of megabytes even on small files and dies outright on large ones. If your job is to read data out of Excel rather than edit a workbook, there is a sharper tool: FastExcelReader streams XLSX and CSV — fast and with almost flat memory — without losing dates, styles, merged cells or images. An overview of the reader.
XLSX isn’t an “Excel document” — it’s a ZIP archive of XML files. This article breaks down the internals of the format and explains why streaming writes are fundamentally more efficient than the object model when generating large Excel files in PHP.
Generating Excel in PHP looks like a simple task — right up until the file grows to hundreds of thousands of rows and the script hits its memory limit or dies on a timeout. This is an article about the philosophy of FastExcelPhp and the problems this family of libraries solves.
Why do you need FastExcelWriter when the excellent PhpSpreadsheet already exists? Because it is simply better — faster, leaner and more concise.