KoolReport's Forum

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

Excel corrupted file #2506

Open Epitello opened this topic on on Dec 24, 2021 - 10 comments

Epitello commented on Dec 24, 2021

Hi,

I have problems with export to excel. The file is corrupted with the array datasource but not with csv datasource.

MyReport.php

Excel.view.php

Thanks

Sebastian Morales commented on Dec 27, 2021

Would you pls open your excel file in a text editor (says, Visual Studio Code) to see if there's any warning/error text in there? Tks,

Epitello commented on Dec 30, 2021

The file is not very readable but there is {} at the end of file. Is it normal ?

Thanks

Sebastian Morales commented on Dec 31, 2021

I think not. {} could be string output of an empty object. It's advisable to use return; or exit; right after the export command so that no unwanted output accidently follow excel or pdf content:

$report
run()
->exportToExcel(...)
->toBrowser("MyReport.xls"); 
return; // or exit;
Epitello commented on Jan 4, 2022

I resolved this bug. After the export, I remplaced "return new JsonResponse()" by "return new Response()". We're using Symfony.

But I have another problem: I have a report with multiple graphics, when I want to export to excel, I have the following error :

Thanks

Sebastian Morales commented on Jan 5, 2022

Pls try with each one chart first to see which one caused the error. When you find one pls post your excel view file content with that chart. Rgds,

Epitello commented on Jan 5, 2022

The error was caused by a column chart (with data). The export to excel works when the column chart has no data.

The excel view is complex, I post a dump of the column chart

Sebastian Morales commented on Jan 5, 2022

Pls post the column chart's php create code and print out its datasource's data for us to check them for you. Tks,

Epitello commented on Jan 5, 2022

The column chart's php create code:

data:

Sebastian Morales commented on Jan 6, 2022

The column chart error is because no data is provided for it. When its datastore is not empty. pls replace your excel Column chart with an excel Table to see if export works and how the datastore's data is rendered. Rgds,

Epitello commented on Jan 7, 2022

The problem is solved. The datastore columns and those of chart was different. 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
bug
solved

Excel