KoolReport's Forum

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

Export report parameters to excel #599

Closed Eugene opened this topic on on Jan 20, 2019 - 11 comments

Eugene commented on Jan 20, 2019

Hi,

is it possible to add to excel some report's parameters? For example, if on the report page I set a date range - I know how to send these parameters to create the correct report and export it to excel, but I would like to have in excel file this date range also.

Also, could I add a title to the excel sheet before the report? And I've noticed that there is no footer in the excel file. I can understand the reason but is it possible to make the excel view same as the screen view?

David Winterburn commented on Jan 21, 2019

Hi Eugene,

We are going to release a new version of the Excel package which supports Excel export template. With this new feature you could add and customize report data to the exported excel file like what you describe.

We will notify you via this topic when the new version is released. Thanks!

Eugene commented on Jan 21, 2019

It sounds great... do you need any beta-testers? :-)))

David Winterburn commented on Jan 21, 2019

Hi Eugene,

Please send us an email to support@koolphp.net with title "development Excel package". We are very happy to send you a development version of the Excel package. There could be some minor differences in the final API but most should be consistent enough. Thanks!

Eugene commented on Jan 23, 2019

I was too optimistic in one of my previous messages. I follow all the recommendations but I can export the report with default parameters only. How to export the report with parameters from my current view where i set the date range for example.

David Winterburn commented on Jan 23, 2019

Hi Eugene,

In the excel template file (e.g, MyReport.excel.file) you have access to the current report via $this and its parameters via $this->params. So says you want to add your date range parameters to the excel file, one way is to add the followng code:

    <div range="A2:D2" >
        <?php echo "From: " . $this->params["fromDate"] . " to: " . $this->params["toDate"]; ?>
    </div>

To update parameters with the current view when export, you export button should submit your form via post/get method. For example:

<button type="submit" formaction="exportToExcel.php">Export to Excel</button>

Please let us know if we understand your question correctly. Thanks!

Eugene commented on Jan 23, 2019

:-) thanks but with every answer I have more and more questions.

  1. Your example with div it is about your new version of the Excel package? But I still have the old (current) one.

  2. upd... see next comment

Eugene commented on Jan 23, 2019

I think I found the problem - if I added the export button to the same form with datepicker everything works and excel report looks as I expect. But it means I have to keep the input control and export button in one form. But if I cannot do it, for example, I need to show the export button after the report table and datepicker before the table so it can not be one form. What to do in this case?

KoolReport commented on Jan 23, 2019

If it is the case you add id to your form <form id="my-form" ... then on the Export button (which you can put anywhere), you do:

<button onclick="$('#my-form').submit()">Export</button>
Eugene commented on Jan 23, 2019

Thank you.

But what did mean David with the example for excel template? Does it work for the current excel package version?

David Winterburn commented on Jan 23, 2019

You could set your form's when exporting as well:

var myForm = document.querySelector("#my-form");
myForm.action = "exportExcel.php";
myForm.submit();
Eugene commented on Jan 23, 2019

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
solved

Excel