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
21focused categories
5implementation paths
01Remove DuplicatesDeduplicate rows by a stable business key before generating the workbook.
EasyPHP preprocessing+
Deduplicate rows by a stable business key before generating the workbook.
MnbExcel::fromArray()<?php
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');02Text to ColumnsSplit a delimited source field into independent workbook columns.
EasyPHP preprocessing+
Split a delimited source field into independent workbook columns.
array_map()MnbExcel::fromArray()<?php
use Mnb\PHPExcel\MnbExcel;
$expanded = array_map(static function (array $row): array {
[$city, $state] = array_pad(array_map('trim', explode(',', $row['Location'], 2)), 2, '');
return $row + ['City' => $city, 'State' => $state];
}, $rows);
MnbExcel::fromArray($expanded)
->withHeader()
->save('text-to-columns.xlsx');03Flash FillReproduce a predictable Flash Fill transformation in PHP so the rule is explicit and testable.
EasyPHP preprocessing+
Reproduce a predictable Flash Fill transformation in PHP so the rule is explicit and testable.
array_map()MnbExcel::fromArray()<?php
use Mnb\PHPExcel\MnbExcel;
$filled = array_map(static function (array $row): array {
$parts = preg_split('/\s+/', trim($row['Full name'])) ?: [];
$row['Initials'] = implode('', array_map(
static fn (string $part): string => strtoupper(substr($part, 0, 1)),
$parts
));
return $row;
}, $rows);
MnbExcel::fromArray($filled)
->withHeader()
->save('flash-fill-equivalent.xlsx');04Power Query ImportBuild a repeatable PHP ETL pipeline that reads source data, transforms it, and writes a clean XLSX output.
AdvancedPHP preprocessing+
Build a repeatable PHP ETL pipeline that reads source data, transforms it, and writes a clean XLSX output.
MnbExcel::read()rows()MnbExcel::fromArray()<?php
use Mnb\PHPExcel\MnbExcel;
$rows = MnbExcel::read('supplier.csv')
->sheet(1)
->withHeader()
->rows();
$clean = array_map(static fn (array $row): array => [
'SKU' => strtoupper(trim($row['sku'])),
'Description' => trim($row['description']),
'Price' => (float) $row['price'],
], $rows);
MnbExcel::fromArray($clean)
->withHeader()
->currencyColumns(['Price'], '$')
->save('supplier-import.xlsx');Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue