MNB PHPExcelDeveloper Guide

Testing examples

Testing Excel examples, explained clearly.

Open a focused example to see the implementation path, copy-ready PHP, expected workbook behavior, and the production boundary that matters.

3examples in this category
21supported categories
5implementation paths
Monolithic library

Testing examples with copy-ready, production-minded PHP.

Each example identifies the exact methods it uses and can be opened independently from the right-side index.

3
examples
10
documented methods
Example 01

Validate generated XLSX integrity

strictXlsxIntegrityValidation()MnbExcel::validateXlsx()MnbExcel::assertValidXlsx()
validate-generated-xlsx-integrity.php
<?php

declare(strict_types=1);

/*
Summary:
    Validate package relationships, required parts, content types, and XML after generating a
    workbook.

Implementation note:
    XLSX saves are validated automatically. The public validation methods are useful for uploaded
    fixtures, CI checks, and explicit release assertions.
*/

use Mnb\PHPExcel\MnbExcel;

$output = __DIR__ . '/output/invoices.xlsx';

MnbExcel::fromArray([
    ['invoice' => 'INV-001', 'customer' => 'Ava', 'total' => 1250.50],
    ['invoice' => 'INV-002', 'customer' => 'Noah', 'total' => 980.00],
])
    ->withHeader()
    ->strictXlsxIntegrityValidation()
    ->save($output);

$result = MnbExcel::validateXlsx($output);

if (!$result['valid']) {
    throw new RuntimeException(implode('; ', $result['errors']));
}

MnbExcel::assertValidXlsx($output);