KoolReport's Forum

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

Unreadable content in Excel export #972

Open Toby Beresford opened this topic on on Jul 4, 2019 - 5 comments

Toby Beresford commented on Jul 4, 2019

Heya I've just purchased the koolreport/excel package for a project. Whenever I export to Excel Excel opens with an error message - unreadable content? "We found a problem with some content in 'recruitment-report-2019-07-04 (4).xlsx'. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."

Have you seen this issue before, do you know what might causing this? I can see this irritating the customer if they have to click through these popups every day.

Thanks Toby

David Winterburn commented on Jul 5, 2019

Hi Toby,

Please send us one of the excel file with problem to our email support@koolphp.net. Thanks!

Toby Beresford commented on Jul 5, 2019

Thanks David. Sent. Hope you can sleuth out the issue!

David Winterburn commented on Jul 5, 2019

Thanks, Toby! I've looked into your excel file and it seems after the excel content there're html content at the end of the file which corrupts it as an excel file:

//yourFile.xlsx
{excel content}
<link rel='stylesheet' type='text/css' property='stylesheet' href='//rwc.localhost/_debugbar/assets/stylesheets?v=1553506748'><script type='text/javascript' src='//rwc.localhost/_debugbar/assets/javascript?v=1553506748'></script><script type="text/javascript">jQuery.noConflict(true);</script>
...

This indicates that after your export command, there're still more outputs in your page. Please make sure that your php stop executing or outputing any html content after the export command. One fast and hacky solution is to put the exit command after export:

...
->toBrowser("yourFile.xlsx");
exit;

But I don't recommend using this as a long term solution. It's better if you could clean your code structure to better understand its output flow. Thanks!

Toby Beresford commented on Jul 5, 2019

Great thanks David! It's the laravel debugger that's getting in the way. I will sort out.

paulo commented on Aug 29, 2019

Hi Toby, how did you sort this out? I might have the same issue. do you mind sharing ? 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

Excel