justkawal / excel

Excel Library for Flutter and Dart - https://pub.dev/packages/excel
MIT License
416 stars 229 forks source link

Error opening xlsx file on Excel #318

Open btrincao-i9 opened 8 months ago

btrincao-i9 commented 8 months ago

Developing with version excel: 4.0.2

Error:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><logFileName>Repair Result to output_file_name (4)0.xml</logFileName><summary>Errors were detected in file ’/Users/xxxx/Downloads/output_file_name (4).xlsx’</summary><removedParts summary="Following is a list of removed parts:"><removedPart>Replaced Part: /xl/worksheets/sheet1.xml part with XML error.  Load error.</removedPart></removedParts></recoveryLog>

It's working when file is opened in Google Sheets.

Already tried deleting sheet1, but got the same error. Any ideas?

btrincao-i9 commented 8 months ago

I think I had some configuration on that file that was locking Sheet1 from being created, and that was not working correctly with sheets.

Created a new one with a default sheet name and the same layout and formulas. Now it works but still got this error:

`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

Repair Result to output_file_name (8)0.xmlErrors were detected in file ’/Users/xxxx/Downloads/output_file_name (8).xlsx’Removed Records: Formula from /xl/calcChain.xml part (Calculation properties)` I guess the calcChain its the file where the formulas are stored for this excel file.
eK14u commented 7 months ago

same issue

splohmer commented 6 months ago

I have the same issue.

splohmer commented 6 months ago

Hi, I was in contact with Kawal the main developer of this library. He mentions that there will be a bigger release in the next time which should solve this issue. Meanwhile I found out that the root cause in my case is that the calcChain.xml inside the Excel is not updated and therefore I got always the error when opening. As a workaround I identified for me that in save_file.dart#_cloneArchive the line

clone.addFile(copy);

can be replaced by

if (file.name != "xl/calcChain.xml") { clone.addFile(copy); }

this prevents the old calcChain.xml to be stored to the newly saved version of the excel. As of now this stopped the error message when opening the excel sheet after changing things with this library.

Important: As I do not really use formulars in my excel, I didn't saw any downsides for this yet, but it might impact Excel Sheets with Formulas inside.

Regards, Sven

tigershinny commented 5 months ago

Works fine when remove setDefaultColumnWidth for Sheet