MNB PHPExcelDeveloper Guide

Charts examples

Charts 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

Charts 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
2
documented methods
Example 01

Column Chart

addChart()
column-chart.php
<?php

declare(strict_types=1);

/*
Summary:
    Create a native column chart from category and value ranges.

Implementation note:
    Column charts are effective for comparing discrete categories.
*/

use Mnb\PHPExcel\MnbExcel;

MnbExcel::fromArray($monthlySales)
    ->withHeader()
    ->addChart('column', 'Monthly Sales', [[
        'name' => 'Sales',
        'categories' => 'Sheet1!$A$2:$A$13',
        'values' => 'Sheet1!$B$2:$B$13',
    ]], ['from' => 'D2', 'to' => 'L18'])
    ->save('column-chart.xlsx');