MNB PHPExcelDeveloper Guide

Math examples

Math 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

Math 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
2
documented methods
Example 01

ROUND

MnbExcel::formula()decimalColumns()
round.php
<?php

declare(strict_types=1);

/*
Summary:
    Round a number to a chosen number of decimal places.

Implementation note:
    Number formatting changes display only; ROUND changes the calculated value.
*/

use Mnb\PHPExcel\MnbExcel;

$rows = [[
    'Raw amount' => 1299.4567,
    'Rounded' => MnbExcel::formula('ROUND(A2,2)', 1299.46),
]];

MnbExcel::fromArray($rows)
    ->withHeader()
    ->decimalColumns(['Raw amount', 'Rounded'], 2)
    ->save('round.xlsx');