Dashboard examples
Dashboard 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.
3examples in this category
21supported categories
5implementation paths
Monolithic library
Dashboard 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.
- 3
- examples
- 4
- documented methods
MnbExcel::formula()addChart()styleHeader()<?php
declare(strict_types=1);
/*
Summary:
Build a dashboard worksheet from summary rows, KPI formulas, styles, and several native charts.
Implementation note:
Keep a separate data sheet so dashboard formulas and charts have stable source ranges.
*/
use Mnb\PHPExcel\MnbExcel;
MnbExcel::fromWorkbookArray([
'Data' => $salesRows,
'Dashboard' => [[
'KPI' => 'Revenue',
'Value' => MnbExcel::formula('SUM(Data!D2:D500)', 125_000),
]],
])
->withHeader()
->styleHeader(['font' => ['bold' => true, 'color' => '#FFFFFF'], 'fill' => ['color' => '#0E6B4D']])
->addChart('column', 'Revenue by Month', [[
'categories' => 'Data!$A$2:$A$13',
'values' => 'Data!$D$2:$D$13',
]], ['sheet' => 'Dashboard', 'from' => 'D2', 'to' => 'L18'])
->addChart('doughnut', 'Sales Mix', [[
'categories' => 'Data!$B$2:$B$6',
'values' => 'Data!$D$2:$D$6',
]], ['sheet' => 'Dashboard', 'from' => 'D20', 'to' => 'J34'])
->save('kpi-dashboard.xlsx');preservePivotTablesFrom()<?php
declare(strict_types=1);
/*
Summary:
Preserve slicers from a trusted pivot-table template and replace the source data safely.
Implementation note:
Slicers are preserved through trusted templates; they are not generated from scratch by the
builder.
*/
use Mnb\PHPExcel\MnbExcel;
MnbExcel::fromWorkbookArray([
'Data' => $salesRows,
'Dashboard' => [],
])
->withHeader()
->preservePivotTablesFrom(
'templates/dashboard-with-slicers.xlsx',
sourceSheet: 'Data',
sourceRange: 'A1:F500'
)
->save('dashboard-with-slicers.xlsx');preservePivotTablesFrom()<?php
declare(strict_types=1);
/*
Summary:
Preserve an existing pivot timeline from a trusted template and rebind its pivot source range.
Implementation note:
The source date column must contain true Excel dates. Timelines are preserved rather than
authored directly.
*/
use Mnb\PHPExcel\MnbExcel;
MnbExcel::fromWorkbookArray([
'Data' => $datedSalesRows,
'Dashboard' => [],
])
->withHeader()
->preservePivotTablesFrom(
'templates/dashboard-with-timeline.xlsx',
sourceSheet: 'Data',
sourceRange: 'A1:G1000'
)
->save('dashboard-with-timeline.xlsx');No matching example found.Try a method name, task, or result.
Was this guide useful?Use GitHub issues for corrections, missing examples, or unclear behavior.
Open an issue