XLS · Basic
XLS basic 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
Basic 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
- 4
- documented methods
Xls::write()<?php
declare(strict_types=1);
/*
Summary:
Generate a native Excel 97–2003 workbook with a header row and named worksheet.
Implementation note:
Use XLS only when a legacy integration requires BIFF8. Choose XLSX for modern capacity and
richer presentation features.
*/
use Mnb\PHPExcel\Format\Xls;
Xls::write([
['Name' => 'Alice', 'Amount' => 1250.50, 'Approved' => true],
['Name' => 'Bob', 'Amount' => 875.00, 'Approved' => false],
], __DIR__ . '/report.xls', [
'with_header' => true,
'sheet_name' => 'Data',
]);CellValue::date()CellValue::number()CellValue::formula()Xls::write()<?php
declare(strict_types=1);
/*
Summary:
Write dates, numbers, and BIFF8 formulas with an explicit cached result.
Implementation note:
BIFF8 has fixed worksheet capacity and a smaller presentation feature set. Enable strict feature
handling when silent degradation is unacceptable.
*/
use Mnb\PHPExcel\Core\CellValue;
use Mnb\PHPExcel\Format\Xls;
Xls::write([
['Date', 'Amount', 'Double'],
[
CellValue::date('2026-07-29'),
CellValue::number('1250.50'),
CellValue::formula('B2*2', 2501.00),
],
], __DIR__ . '/typed.xls');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