MNB PHPExcelDeveloper Guide

XLSX · Structured output

XLSX structured output 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 · 3 methods
XLSX individual library

Structured output 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
3
documented methods
Example 01

Return structured XLSX data from an API

Open related guide
toStructuredArray()toStructuredWorkbookArray()toStructuredSheetArray()
return-structured-xlsx-data-from-an-api.php
<?php

declare(strict_types=1);

/*
Summary:
    Convert the selected workbook into a native structured array with sheet and source metadata.

Implementation note:
    Structured terminal methods return native values. Read summary, rows, warnings, and source
    metadata directly from the returned array.
*/

use Mnb\PHPExcel\Format\Xlsx;

$payload = Xlsx::read(__DIR__ . '/orders.xlsx')
    ->withHeaderRow(1)
    ->toStructuredArray([
        'include_workbook' => true,
        'include_sheets' => true,
        'preserve_original_row_numbers' => true,
    ]);

header('Content-Type: application/json; charset=UTF-8');
echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);