XLS · Reading
XLS reading 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.
XLS individual library
Reading examples with copy-ready, production-minded PHP.
Every snippet uses mnb/mnb-phpexcel-xls or its declared Core dependency. Each copied snippet includes strict typing, a concise summary, implementation guidance, readable limits, and a safe fixture check.
- 2
- examples
- 5
- documented methods
Xls::read()sheet()withHeaderRow()rows()<?php
declare(strict_types=1);
/*
Summary:
Stream a named BIFF8 worksheet as associative rows with upload-friendly limits.
Implementation note:
The native reader handles OLE/CFB and BIFF8 directly. Keep application upload limits lower than
parser safety limits.
*/
use Mnb\PHPExcel\Format\Xls;
foreach (Xls::read(__DIR__ . '/customers.xls')
->sheet('Customers')
->withHeaderRow(1)
->rows([
'skip_empty_rows' => true,
'max_rows' => 5_000,
]) as $row) {
echo $row['Name'] . PHP_EOL;
}Xls::read()toArray()<?php
declare(strict_types=1);
/*
Summary:
Read BIFF8 formula text, cached values, or both representations from the same worksheet.
Implementation note:
The combined mode preserves the formula and cached result, which is useful when PHP should
inspect rather than recalculate legacy formulas.
*/
use Mnb\PHPExcel\Format\Xls;
$session = Xls::read(__DIR__ . '/calculations.xls')
->sheet('Summary');
$formulas = $session->toArray(['formula_cells' => 'formula']);
$cached = $session->toArray(['formula_cells' => 'cached_value']);
$both = $session->toArray(['formula_cells' => 'both']);No matching example found.Try a method name, task, or result.
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue