KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.

Unreadable content in Excel export #972

Open Toby Beresford opened this topic on on Jul 4 - 4 comments

Toby Beresford commented on Jul 4

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

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

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

David Winterburn commented on Jul 5

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

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

Give tips to supporter for his good work

If you feel that supporter has done a good work, consider giving him some credit. Any amount put into the tips box below is appreciated. By doing so, you have contribtuted to the existence of KoolReport and the quality of support.

Tips box
help needed

Excel