MNB PHPExcelDeveloper Guide

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
21focused categories
5implementation paths
01
KPI Dashboard

Build a dashboard worksheet from summary rows, KPI formulas, styles, and several native charts.

AdvancedDirect API
MnbExcel::formula()addChart()styleHeader()
kpi-dashboard.php
<?php

use Mnb\PHPExcel\MnbExcel;

MnbExcel::fromWorkbookArray([
    'Data' => $salesRows,
    'Dashboard' => [[
        'KPI' => 'Revenue',
        'Value' => MnbExcel::formula('SUM(Data!D2:D500)', 125000),
    ]],
])
    ->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');
02
Slicers

Preserve slicers from a trusted pivot-table template and replace the source data safely.

MediumTrusted template
preservePivotTablesFrom()
slicers.php
<?php

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');
03
Timeline Filter

Preserve an existing pivot timeline from a trusted template and rebind its pivot source range.

MediumTrusted template
preservePivotTablesFrom()
timeline-filter.php
<?php

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');