KoolReport's Forum

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

Pivot matrix excel export #1113

Open Ralf Föhring opened this topic on on Oct 8, 2019 - 4 comments

Ralf Föhring commented on Oct 8, 2019

Hi, is there any way to keep the pivot matrix current groupings when exporting it to excel ? Because it looks like it uses the default grouping.

David Winterburn commented on Oct 8, 2019

Hi Ralf,

Please put your pivot matrix inside a form together with your Export button and this hidden input:

<input type='hidden' name='koolPivotUpdate' value=1 />

Let me know if it solves your export problem. Thanks!

Ralf Föhring commented on Oct 8, 2019

Nope it's not changing anything.

This is the exporting code:

include "MyReport.php";
$report = new MyReport;
$report->run()->exportToExcel('MyReportExcel')->toBrowser("MyReport.xlsx");
David Winterburn commented on Oct 9, 2019

Hi Ralf,

The form should have method="post" and the Excel export button should be like this:

<form id='form1' class="form-inline" method="post">
                <button formaction='exportExcel.php'>Export Excel</button>
                <input type='hidden' name='koolPivotUpdate' value=1 />
                <?php
                PivotMatrix::create(array(
                    "id" => "pivotMatrix1",
                    'dataSource' => $this->dataStore('sales'),
                ...
</form>

and exportExcel.php should be:

require_once "MyReport.php";
$report = new MyReport();

$report->run()->exportToExcel('MyReportExcel')->toBrowser("MyReport.xlsx");

Thanks!

Ralf Föhring commented on Oct 11, 2019

You're right. Thanks.

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
help needed

Pivot