MNB PHPExcelDeveloper Guide

Text examples

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

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

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

4
examples
1
documented methods
Example 01

LEFT, RIGHT, MID

MnbExcel::formula()
left-right-mid.php
<?php

declare(strict_types=1);

/*
Summary:
    Extract fixed portions of identifiers and codes with Excel text formulas.

Implementation note:
    Store extracted numeric-looking identifiers as text when leading zeroes matter.
*/

use Mnb\PHPExcel\MnbExcel;

$rows = [[
    'Code' => 'INV-2026-0042',
    'Prefix' => MnbExcel::formula('LEFT(A2,3)', 'INV'),
    'Number' => MnbExcel::formula('RIGHT(A2,4)', '0042'),
    'Year' => MnbExcel::formula('MID(A2,5,4)', '2026'),
]];

MnbExcel::fromArray($rows)
    ->withHeader()
    ->save('text-parts.xlsx');