KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

PivotMatrix export excel and zero value #2708

Closed Edp Ferrino opened this topic on on Jun 6, 2022 - 6 comments

Edp Ferrino commented on Jun 6, 2022

If I follow the example at this link

https://www.koolreport.com/examples/reports/excel/pivotmatrix/

it happens that when I export on excel sheet the zero value is replaced with the value -

How do I get it to export the zero?

Sebastian Morales commented on Jun 7, 2022

All of web's and excel's PivotMatrix and PivotTable widgets have a property called "emptyValue" which is default to "-". Set it to 0 like this in the excel view for your case:

//MyReportExcel.view.php
\koolreport\excel\PivotMatrix::create(array(
    ...
    "emptyValue" => 0,
));
Edp Ferrino commented on Jun 7, 2022

It did not work

Sebastian Morales commented on Jun 8, 2022

Pls open the file koolreport/pivot/PivotUtil.php and add the following line to function computeDataCellMaps():

    protected function computeDataCellMaps()
    {
        $cMetas = $this->dataStore->meta()['columns'];
        $cellMap = Util::get($this->map, 'dataCell', function ($v, $info) use ($cMetas) {
            if (!isset($v)) return $this->emptyValue; // add this line

We will apply a fix in the next version of KoolReport. Rgds,

Edp Ferrino commented on Jun 8, 2022

Notice: Undefined property: koolreport\pivot\PivotUtil::$emptyValue in koolreport/pivot/PivotUtil.php on line 476

Sebastian Morales commented on Jun 8, 2022

Sorry, pls add this line in function __construct as well:

    public function __construct(&$dataStore, $params = [])
    {
        ...
        $this->totalName = Util::get($this->params, 'totalName', 'Total');
        $this->emptyValue = Util::get($this->params, 'emptyValue', '-'); // add this line
Edp Ferrino commented on Jun 8, 2022

Solved. Thank you

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
None yet

None