Fast Excel 5.x: Streaming Imports &amp; Safer Exports | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. Fast Excel 5.x Adds Streaming Imports and Safer Exports for Laravel

   [Laravel](https://www.msaied.com/public/articles?category=laravel) [Composer Pacakge](https://www.msaied.com/public/articles?category=composer-pacakge) 

 Fast Excel 5.x Adds Streaming Imports and Safer Exports for Laravel
====================================================================

 Fast Excel 5 brings lazy streaming imports via LazyCollection, chunked import controls with headerRow() and startRow(), sheet and column selection, and formula-injection protection with escapeFormulas().

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 20 Sep 2026 · Updated 22 Sep 2026 · 4 min read

ShareCopy linkCopied

 ![Fast Excel 5.x Adds Streaming Imports and Safer Exports for Laravel](https://cdn.msaied.com/691/336355c7690e72d026fa4cc54943c82b.png) 

  On this page +1. [Fast Excel 5.x: Streaming Imports and Safer Exports](#fast-excel-5x-streaming-imports-and-safer-exports)
2. [Lazy Imports for Large Files](#lazy-imports-for-large-files)
3. [Chunked Imports with Stable Headings](#chunked-imports-with-stable-headings)
4. [Selecting Sheets and Columns](#selecting-sheets-and-columns)
5. [Escaping Spreadsheet Formulas](#escaping-spreadsheet-formulas)
6. [Compatibility and Installation](#compatibility-and-installation)
7. [Key Takeaways](#key-takeaways)

 Fast Excel 5.x: Streaming Imports and Safer Exports
---------------------------------------------------

Fast Excel has grown well beyond its v2.2 roots of simple collection exports and browser downloads. The 5.x release series adds lazy streaming imports, fine-grained chunked import controls, sheet and column selection, and a built-in guard against formula injection — making it a practical choice for large operational data pipelines, not just quick report downloads.

The package continues to use [OpenSpout](https://github.com/openspout/openspout) under the hood, keeping memory usage low by avoiding a full in-memory parse of every spreadsheet.

---

Lazy Imports for Large Files
----------------------------

The original `import()` method loads every row into a collection at once. For large uploads that can exhaust available PHP memory. `importLazy()`, introduced in Fast Excel 5.12, yields rows through a `LazyCollection` so you can process them in batches without holding the entire file in memory:

```php
use App\Models\Contact;
use Illuminate\Support\LazyCollection;
use Rap2hpoutre\FastExcel\FastExcel;

(new FastExcel)->importLazy('contacts.xlsx')
    ->chunk(1_000)
    ->each(function (LazyCollection $contacts) {
        Contact::insert($contacts->all());
    });

```

This pattern is a clean alternative to manual CSV parsing for large file uploads.

---

Chunked Imports with Stable Headings
------------------------------------

When you need a queued job to process only a slice of a spreadsheet, three methods give you precise control:

- `headerRow(int $row)` — reads column keys from the specified heading row
- `startRow(int $row)` — sets where the current chunk begins
- `limitRows(int $count)` — caps the number of rows read

```php
use Rap2hpoutre\FastExcel\FastExcel;

$rows = (new FastExcel)
    ->headerRow(1)
    ->startRow(2 + ($page * 1_000))
    ->limitRows(1_000)
    ->import('orders.xlsx');

```

Before Fast Excel 5.17, `startRow()` also treated the selected row as the heading row, so a later chunk could accidentally use a data row as its keys. `headerRow()` (added in [\#418](https://github.com/rap2hpoutre/fast-excel/pull/418)) separates those two concerns without breaking the existing `startRow()` behaviour.

---

Selecting Sheets and Columns
----------------------------

Fast Excel 5.16 added `sheet()` and `onlyColumns()` to limit exactly what data an import reads:

```php
use Rap2hpoutre\FastExcel\FastExcel;

$orders = (new FastExcel)
    ->sheet('Orders')
    ->onlyColumns(['A', 'B', 'H'])
    ->import('customer-export.xlsx');

```

`onlyColumns()` accepts column letters or one-based integer positions. It prevents empty fields from appearing when spreadsheet formatting extends far beyond the real data. `limitColumns()` is also available when you need every column up to a given position.

---

Escaping Spreadsheet Formulas
-----------------------------

Values that begin with `=`, `+`, `-`, or `@` are interpreted as formulas by most spreadsheet applications. When those values originate from user-controlled input — an uploaded CSV or a database field — an export can inadvertently execute arbitrary formulas when someone opens the file.

Fast Excel 5.17 added `escapeFormulas()` ([\#411](https://github.com/rap2hpoutre/fast-excel/pull/411)) to write such values as plain text:

```php
use Rap2hpoutre\FastExcel\FastExcel;

(new FastExcel($rows))
    ->escapeFormulas()
    ->export('orders.xlsx');

```

This is a straightforward mitigation for CSV/formula injection, a risk that is easy to overlook in report-generation code.

---

Compatibility and Installation
------------------------------

Fast Excel 5 requires **PHP 8.0+** and **Laravel 6–13**. It uses OpenSpout 4. Projects still on Fast Excel 2 (PHP 7 / Laravel 5) need to plan the dependency upgrade separately, as the major-version history includes a move from `box/spout` to `openspout/openspout` and a PHP 8 minimum.

Install via Composer:

```bash
composer require rap2hpoutre/fast-excel

```

---

Key Takeaways
-------------

- `importLazy()` streams rows through `LazyCollection`, avoiding full in-memory loads
- `headerRow()` + `startRow()` + `limitRows()` enable safe, paginated queue-based imports
- `sheet()` and `onlyColumns()` scope imports to exactly the data you need
- `escapeFormulas()` prevents formula injection in user-data exports
- Requires PHP 8.0+ and Laravel 6+; uses OpenSpout 4

---

*Source: [Fast Excel 5.x Adds Streaming Imports and Safer Exports — Laravel News](https://laravel-news.com/fast-excel-5-x)*

- [Laravel](https://www.msaied.com/public/articles?search=Laravel)
- [Fast Excel](https://www.msaied.com/public/articles?search=Fast%20Excel)
- [Excel Import](https://www.msaied.com/public/articles?search=Excel%20Import)
- [OpenSpout](https://www.msaied.com/public/articles?search=OpenSpout)
- [PHP Package](https://www.msaied.com/public/articles?search=PHP%20Package)
- [Formula Injection](https://www.msaied.com/public/articles?search=Formula%20Injection)

 Frequently asked questions 
---------------------------

  What is the difference between import() and importLazy() in Fast Excel 5?`import()` loads all rows into a collection at once, which can exhaust PHP memory on large files. `importLazy()` yields rows through a LazyCollection, letting you process them in chunks without holding the entire spreadsheet in memory.

   How does escapeFormulas() protect against formula injection in Fast Excel?Calling `escapeFormulas()` before exporting causes Fast Excel to write values that start with =, +, -, or @ as plain text rather than formulas. This prevents spreadsheet applications from executing user-controlled values as formulas when the file is opened.

   What are the minimum requirements for Fast Excel 5?Fast Excel 5 requires PHP 8.0 or later and Laravel 6 or later. It uses OpenSpout 4. Projects on PHP 7 or Laravel 5 that rely on Fast Excel 2 need to upgrade those dependencies before moving to version 5.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com/public#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleFilament v5.8.3 Released: Bug Fixes, MFA Improvements, and New Translations](https://www.msaied.com/public/articles/filament-v583-released-bug-fixes-mfa-improvements-and-new-translations) [Next articleDifflock: Lint Laravel Migrations and Diff Your Database Schema](https://www.msaied.com/public/articles/difflock-lint-laravel-migrations-and-diff-your-database-schema)  

   On this page
-------------

1. [Fast Excel 5.x: Streaming Imports and Safer Exports](#fast-excel-5x-streaming-imports-and-safer-exports)
2. [Lazy Imports for Large Files](#lazy-imports-for-large-files)
3. [Chunked Imports with Stable Headings](#chunked-imports-with-stable-headings)
4. [Selecting Sheets and Columns](#selecting-sheets-and-columns)
5. [Escaping Spreadsheet Formulas](#escaping-spreadsheet-formulas)
6. [Compatibility and Installation](#compatibility-and-installation)
7. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
