Fast Excel 5.x: Streaming Imports &amp; Safer Exports | Mohamed Said        [  ![Mohamed Said](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png)   Mohamed Said Laravel Backend Engineer  ](https://msaied.com) [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles  ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

       [  ](https://github.com/EG-Mohamed)       

 [ Home ](https://msaied.com) [ Projects ](https://msaied.com/projects) [ Articles ](https://msaied.com/articles) [ Certificates ](https://msaied.com/certificates) [ Contact ](https://msaied.com#contact-section) 

  [ home ](https://msaied.com)    [ articles ](https://msaied.com/articles)    Fast Excel 5.x Adds Streaming Imports and Safer Exports for Laravel        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 Adds Streaming Imports and Safer Exports for Laravel](https://cdn.msaied.com/691/336355c7690e72d026fa4cc54943c82b.png)

 [  Laravel ](https://msaied.com/articles?category=laravel) [  Composer Pacakge ](https://msaied.com/articles?category=composer-pacakge)  #Laravel   #Fast Excel   #Excel Import   #OpenSpout   #PHP Package   #Formula Injection  

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

     20 Sep 2026      4 min read    ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)  Mohamed Said  

       Table of contents

1. [  01   Fast Excel 5.x: Streaming Imports and Safer Exports  ](#fast-excel-5x-streaming-imports-and-safer-exports)
2. [  02   Lazy Imports for Large Files  ](#lazy-imports-for-large-files)
3. [  03   Chunked Imports with Stable Headings  ](#chunked-imports-with-stable-headings)
4. [  04   Selecting Sheets and Columns  ](#selecting-sheets-and-columns)
5. [  05   Escaping Spreadsheet Formulas  ](#escaping-spreadsheet-formulas)
6. [  06   Compatibility and Installation  ](#compatibility-and-installation)
7. [  07   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)*

 Found this useful?

          [  ](https://twitter.com/intent/tweet?url=https%3A%2F%2Fmsaied.com%2Farticles%2Ffast-excel-5x-adds-streaming-imports-and-safer-exports-for-laravel&text=Fast+Excel+5.x+Adds+Streaming+Imports+and+Safer+Exports+for+Laravel) [  ](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fmsaied.com%2Farticles%2Ffast-excel-5x-adds-streaming-imports-and-safer-exports-for-laravel) 

 Frequently Asked Questions 
----------------------------

  3 questions  

     Q01  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. 

      Q02  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. 

      Q03  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. 

  Continue reading

 More Articles 
---------------

 [ View all    ](https://msaied.com/articles) 

 [ ![Livewire v4.4.6 Released: Bug Fixes, Test Improvements, and Alpine v3.17.4](https://cdn.msaied.com/689/454c52282f3ef5d585905e5952ca969c.png) Livewire Laravel Alpine.js 

### Livewire v4.4.6 Released: Bug Fixes, Test Improvements, and Alpine v3.17.4

Livewire v4.4.6 ships with 18 changes including validation performance improvements, better test assertions, k...

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

 21 Sep 2026     3 min read  

  Read    

 ](https://msaied.com/articles/livewire-v446-released-bug-fixes-test-improvements-and-alpine-v3174) [ ![Laravel 14: New Features, Breaking Changes, and PHP 8.4 Requirement](https://cdn.msaied.com/688/2dfe8f11b0bef35c0ee6db912004209f.png) Laravel 14 PHP 8.4 Breaking Changes 

### Laravel 14: New Features, Breaking Changes, and PHP 8.4 Requirement

Laravel 14 is expected in Q1 2027 and will require PHP 8.4. Here is everything known so far from the master br...

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

 21 Sep 2026     4 min read  

  Read    

 ](https://msaied.com/articles/laravel-14-new-features-breaking-changes-and-php-84-requirement) [ ![Building a Laravel Package: Service Providers, Auto-Discovery, and Config Merging](https://cdn.msaied.com/687/e53f819c8f897c1ad12a1df0661a18f7.png) laravel packages service-providers 

### Building a Laravel Package: Service Providers, Auto-Discovery, and Config Merging

Learn how to build a production-ready Laravel package from scratch — covering service provider design, auto-di...

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

 21 Sep 2026     1 min read  

  Read    

 ](https://msaied.com/articles/building-a-laravel-package-service-providers-auto-discovery-and-config-merging-4) 

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

Explore

- [Home](https://msaied.com)
- [Projects](https://msaied.com/projects)
- [Articles](https://msaied.com/articles)
- [Certificates](https://msaied.com/certificates)
- [Contact](https://msaied.com#contact-section)

Connect

- [   hello@msaied.com ](mailto:hello@msaied.com)
- [   +20 109 461 9204 ](tel:+201094619204)

© 2026 Mohamed Said. All rights reserved.

 [  ](https://github.com/EG-Mohamed) [  ](https://www.linkedin.com/in/msaiedm/) [  ](https://wa.me/201094619204) [  ](mailto:hello@msaied.com) [  ](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
