MNB PHPExcelDeveloper Guide

XLSX · Large files

XLSX large files examples.

Package-local, copy-ready examples organized like the classes and methods reference. Open one example at a time, search by method, and jump from the right-side index.

Packagemnb/mnb-phpexcel-xlsx:^2.0Reference1 examples · 4 methods
XLSX individual library

Large files examples with copy-ready, production-minded PHP.

Every snippet uses mnb/mnb-phpexcel-xlsx or its declared Core dependency. Each copied snippet includes strict typing, a concise summary, implementation guidance, readable limits, and a safe fixture check.

1
examples
4
documented methods
Example 01

Stream projected XLSX columns in chunks

Open related guide
projectColumns()range()streaming()chunks()
stream-projected-xlsx-columns-in-chunks.php
<?php

declare(strict_types=1);

/*
Summary:
    Project only required columns and process large worksheets in bounded batches.

Implementation note:
    Projection reduces retained cell data before each batch reaches application code. Tune chunk
    size to row width and downstream work.
*/

use Mnb\PHPExcel\Format\Xlsx;

$session = Xlsx::read(__DIR__ . '/orders.xlsx')
    ->sheet('Orders')
    ->withHeaderRow(1)
    ->projectColumns(['Order ID', 'Customer', 'Total'])
    ->range(startRow: 1, endRow: 250_000)
    ->streaming();

foreach ($session->chunks(1_000) as $chunk) {
    processOrders($chunk);
}