KoolReport's Forum

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

Exporting To Excel #327

Open Gijo George opened this topic on on Jun 21, 2018 - 6 comments

Gijo George commented on Jun 21, 2018

Hi,

I have integrated koolreport to codeigniter. Now I am trying to export a report to Excel using the code $report = new SponsorReportData(); $report->run()->exportToExcel()->toBrowser("myreport.xlsx"); But instead of generating the report, it downloads the html file as .xlsx file. Can anybody help me to resolve the issue?

David Winterburn commented on Jun 21, 2018

Hi George,

Can you please us your php codes as well as a sample of your data? Thanks!

Gijo George commented on Jun 21, 2018

I am calling the export from form submit. if(isset($_POST['submit'])){ $report = new SponsorReportData(); $report->run()->exportToExcel()->toBrowser("myreport.xlsx"); }

Gijo George commented on Jun 21, 2018

I made the following change in the library file \packages\ExcelExportable.php $objWriter = \PHPExcel_IOFactory::createWriter($excel, 'Excel2007'); $objWriter->save('excelreports/DBExport.xlsx'); Now in the excelreports directory of the server the correct Excel file is saved. But when I try to get it in browser as it was earlier, it contains both html content as well as excel content.Is this because of some header issue? I hope this will help in troubleshooting the issue.

David Winterburn commented on Jun 21, 2018

Hi George,

I think it's because you submit the export button to the same report page so it will output the same report header and html first. Later the report could not send an exported excel file to your browser because it already sent header with html data.

Please try to export in the following way, create a php file called myReportExcelExport.php with your export code:

$report = new SponsorReportData(); $report->run()->exportToExcel()->toBrowser("myreport.xlsx");

Then in your report page, use the following export button:

<button type="submit" class="btn btn-primary exportBtn" formaction="myReportExcelExport.php">Export to Excel</button>

Please try this and let us know if there's any problem. Thanks!

Gijo George commented on Jun 21, 2018

Thanks, that worked. Is there anyway I can get the total amount displayed at the bottom?

Landon Evans commented on Feb 19, 2019

you could also use Z---. it may help you. it's easy to use and one of the fastest SDK. you can find more info on https://z----.com/.

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