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
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
Example 01

KPI Dashboard

MnbExcel::formula()addChart()styleHeader()
kpi-dashboard.php
<?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');