MNB PHPExcelDeveloper Guide

Data examples

Data 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

Data 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
4
documented methods
Example 01

Remove Duplicates

MnbExcel::fromArray()
remove-duplicates.php
<?php

declare(strict_types=1);

/*
Summary:
    Deduplicate rows by a stable business key before generating the workbook.

Implementation note:
    Choose an explicit key. Comparing entire rows can keep records that are logically duplicates but
    differ in whitespace or case.
*/

use Mnb\PHPExcel\MnbExcel;

$unique = [];
foreach ($rows as $row) {
    $key = strtolower(trim((string) $row['Email']));
    $unique[$key] ??= $row;
}

MnbExcel::fromArray(array_values($unique))
    ->withHeader()
    ->save('unique-contacts.xlsx');