MNB PHPExcelDeveloper Guide

XLSX · Basic

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

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

Basic 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
1
documented methods
Example 01

Write an XLSX workbook

Open related guide
Xlsx::write()
write-an-xlsx-workbook.php
<?php

declare(strict_types=1);

/*
Summary:
    Write associative rows to a named worksheet with a generated header row.

Implementation note:
    Xlsx::write() is the focused export path. Use the richer workbook data model when the output
    needs multiple sheets or presentation objects.
*/

use Mnb\PHPExcel\Format\Xlsx;

$rows = [
    ['order_id' => 'SO-1001', 'customer' => 'Acme', 'amount' => 1250.50],
    ['order_id' => 'SO-1002', 'customer' => 'Northwind', 'amount' => 840.00],
];

Xlsx::write($rows, __DIR__ . '/orders-export.xlsx', [
    'sheet_name' => 'Orders',
    'with_header' => true,
]);