Skip to content
MNB PHPExcelDeveloper Guide
AI

Printing examples

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

Monolithic library

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

2
examples
2
documented methods
Example 01

Print Area

preserveAdvancedObjectsFrom()
print-area.php
<?php

declare(strict_types=1);

/*
Summary:
    Define the print area in an Excel template and preserve its worksheet settings while replacing
    the data.

Implementation note:
    The current builder does not expose a print-area method. Template preservation retains the
    workbook print definition.
*/

use Mnb\PHPExcel\MnbExcel;

MnbExcel::report($rows)
    ->withHeader()
    ->preserveAdvancedObjectsFrom('templates/a4-print-area.xlsx')
    ->save('print-ready-report.xlsx');
Example 02

Page Layout