Excel Report

The exampe show how to use Excel as DataSource

orderMonthdollar_sales
Jan $696,042
Feb $735,098
Mar $737,920
Apr $718,245
May $869,235
Jun $493,841
Jul $527,504
Aug $597,584
Sep $520,497
Oct $1,014,570
Nov $1,967,316
Dec $705,561

One of the most used source of data is Microsoft Excel and KoolReport does support loading data from Excel file. By acquiring the Excel package, you will be able to load data from excel file and process your data before getting them visualized.

Beside support importing data from Excel file, The Excel package also support exporting your data to Excel file as well. This is very convenient if you want to load your excel file, process data then export back to another excel file as result.

More information of Excel package you may find here.

<?php

require_once "MyReport.php";
$report = new MyReport;
$report->run()->render();
<?php

require_once "../../../load.koolreport.php";

use \koolreport\excel\ExcelDataSource;
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\ColumnMeta;

class MyReport extends \koolreport\KoolReport
{
    protected function settings()
    {
        return array(
            "dataSources"=>array(
                "excel"=>array(
                    "class"=>ExcelDataSource::class,
                    "filePath"=>dirname(__FILE__)."/../../../databases/customer_product_dollarsales2.xlsx",
                )
            )
        );
    }
    protected function setup()
    {
        $this->src("excel")
        ->pipe(new Group(array(
            "by"=>"orderMonth",
            "sum"=>"dollar_sales",
        )))
        ->pipe(new Sort(array(
            "orderMonth"=>"asc",
        )))
        ->pipe(new ColumnMeta(array(
            "orderMonth"=>array(
                "type"=>"date",
                "format"=>"n",
                "displayFormat"=>"M"
            ),
            "dollar_sales"=>array(
                "prefix"=>'$'
            )
        )))        
        ->pipe($this->dataStore("data"));
    }
}
<?php
    use \koolreport\widgets\google\LineChart;
    use \koolreport\widgets\koolphp\Table;
?>

<div class="report-content">
    <div class="text-center">
        <h1>Excel Report</h1>
        <p class="lead">The exampe show how to use Excel as DataSource</p>
    </div>
    <?php
    LineChart::create(array(
        "dataSource"=>$this->dataStore("data"),
        "columns"=>array("orderMonth","dollar_sales")
    ));
    ?>
    <?php
    Table::create(array(
        "dataSource"=>$this->dataStore("data"),
        "columns"=>array("orderMonth","dollar_sales")
    ));
    ?>
</div>
customerNameproductNameproductLineorderDateorderDayorderMonthorderYearorderQuarterdollar_sales
Vitachrome Inc. 1937 Lincoln Berline Vintage Cars 2003-01-10 00:00:00 10 1 2,003 1 3,726
Vitachrome Inc. 1936 Mercedes-Benz 500K Special Roadster Vintage Cars 2003-01-10 00:00:00 10 1 2,003 1 1,768
Baane Mini Imports 1952 Alpine Renault 1300 Classic Cars 2003-01-29 00:00:00 29 1 2,003 1 5,572
Baane Mini Imports 1962 LanciaA Delta 16V Classic Cars 2003-01-29 00:00:00 29 1 2,003 1 5,026
Baane Mini Imports 1958 Setra Bus Trucks and Buses 2003-01-29 00:00:00 29 1 2,003 1 3,284
Baane Mini Imports 1940 Ford Pickup Truck Trucks and Buses 2003-01-29 00:00:00 29 1 2,003 1 3,308
Baane Mini Imports 1926 Ford Fire Engine Trucks and Buses 2003-01-29 00:00:00 29 1 2,003 1 1,283
Baane Mini Imports 1913 Ford Model T Speedster Vintage Cars 2003-01-29 00:00:00 29 1 2,003 1 2,489
Baane Mini Imports 1934 Ford V8 Coupe Vintage Cars 2003-01-29 00:00:00 29 1 2,003 1 2,164
Baane Mini Imports 18th Century Vintage Horse Carriage Vintage Cars 2003-01-29 00:00:00 29 1 2,003 1 2,173

What People Are Saying

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"
-- Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great and amazing."
-- Dr. Lew Choy Onn

"Fantastic framework for reporting!"
-- Greg Schneider

Download KoolReport Get KoolReport Pro