XLS Module
Install and use the fully independent native BIFF8 reader and writer for Excel 97–2003 .xls files.
Updated
Xls::read()Xls::write()XlsReader::sheetNames()What you will learn
- Install native XLS support without an external spreadsheet engine.
- Understand the OLE/CFB and BIFF8 layers handled by the package.
- Choose XLS or XLSX based on compatibility and feature requirements.
Install the native XLS module#
composer require mnb/mnb-phpexcel:^2.0The module requires PHP 8.1+, ext-iconv, and Core. It does not require, suggest, wrap, detect, or call PhpSpreadsheet.
Use the package-local facade#
use Mnb\PHPExcel\Format\Xls;
$rows = Xls::read('report.xls')
->sheet('Data')
->withHeaderRow()
->toArray();
Xls::write($rows, 'report-copy.xls', [
'with_header' => true,
'sheet_name' => 'Data',
]);Understand the native architecture#
| Layer | Responsibility |
|---|---|
| OLE Compound File Binary | Reads and writes the container header, FAT, DIFAT, MiniFAT, directory entries, normal streams, and mini streams. |
| BIFF8 workbook globals | Reads sheet metadata, shared strings, formats, styles, date system, and worksheet offsets. |
| BIFF8 worksheet streams | Reads and writes rows, cells, formulas, merges, dimensions, and pane settings. |
| Core ReadSession | Provides headers, projection, limits, row iteration, arrays, chunks, and normalized errors. |
Choose XLS deliberately#
| Format | Use it when |
|---|---|
| XLS | An existing Excel 97–2003 integration requires BIFF8, or a partner system cannot accept XLSX. |
| XLSX | You need modern workbook features, more rows and columns, Office password encryption, charts, pivots, media, comments, or advanced styling. |
| CSV | Only tabular values matter and the receiving system does not need workbook structure. |
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue