excel
excel copied to clipboard
I moved from version 1.1.5 to 2.0.0-null-safety-3 - wrong decoding
I was using excel 1.1.5 before and had an application where I upload a file and it reads the data on a mobile device. When I moved to version 2.0.0-null-safety-3, uploading the same file it decodes it differently. When decoded after the 25th row it starts misplacing the fields. When I check the whole file decoded - "print(excel.tables[table].rows.toString())" I see that the item "excel.tables[table].rows[i][13].value" its not the same as the one I provided on the file and substitutes it with excel.tables[table].rows[I][3].value on the decoded version. Please I would really appreciate some help.
var filePath = "xxxxxxx";
var bytes = File(filePath).readAsBytesSync();
var excel = Excel.decodeBytes(bytes);
for (var table in excel.tables.keys) {
print(excel.tables[table].rows.toString());
for (int i = 3; i < excel.tables[table].rows.length; i++) {
print(excel.tables[table].rows[i][13].value);
}
What I figured out is that it switches the position of items in the same row in the decoded file Column 3 with Column 13th. After the 25th row, Column 13 becomes Column 3 and Column 3 becomes Column 13.
Another thing that I found is that when I generate the file from the app and load it directly to the app the excel.decode() decodes it correctly. But if the file gets modified from an excel application and then gets loaded excel.decode() decodes it incorrectly.
me also facing this error. f1 | Apple | 500 | Ei | StoreFront | Apple | Fruits | MMK |
-- no problem
f1 | Apple | 500 | Ei | StoreFront | Apple | Fruits | MMK | 300
--error instead of 500 and 300 it showing Datetime String value
Hello everyone - Solution,
After some research and everything I found a workaround that hope it works for some of you. What I did is the following
- I moved from excel 1.1.5 package to a fork of the same library - flutter_excel: ^1.0.1 (https://pub.dev/packages/flutter_excel) - this library pretty much the same and will work with your existing code
Pros/Cons --> even though its a fork the decoding issue is not fixed so pretty much you cannot use it to open excel files reliably --> this library will work with all your other dependencies if upgraded to a newer versions (for example pdf and printing dependencies) --> you can use the library to create all excels and use existing functionalities
- Now for the decoding piece of the excel I used a different package spreadsheet_decoder: ^2.1.1 (https://pub.dev/packages/spreadsheet_decoder) which pretty much works the same way as excel 1.1.5 with the only difference that you need to know the name of the sheet you want to utilize and its not dynamic (still playing with it).
Hello everyone - Solution,
After some research and everything I found a workaround that hope it works for some of you. What I did is the following
- I moved from excel 1.1.5 package to a fork of the same library - flutter_excel: ^1.0.1 (https://pub.dev/packages/flutter_excel) - this library pretty much the same and will work with your existing code
Pros/Cons --> even though its a fork the decoding issue is not fixed so pretty much you cannot use it to open excel files reliably --> this library will work with all your other dependencies if upgraded to a newer versions (for example pdf and printing dependencies) --> you can use the library to create all excels and use existing functionalities
- Now for the decoding piece of the excel I used a different package spreadsheet_decoder: ^2.1.1 (https://pub.dev/packages/spreadsheet_decoder) which pretty much works the same way as excel 1.1.5 with the only difference that you need to know the name of the sheet you want to utilize and its not dynamic (still playing with it).
Thank you for your reply. I love you. I solved problem with your this message. I wish you have a nice day!
@simeonangelov94 @developer-caleb Can you please share the sample example.
Sorry for the trouble.
Can you please confirm that are you having this trouble in latest version: excel: 2.0.1
@justkawal is there any way i can open xlsx file with sheet that contains chart for now it always crashes when opening file with sheets that have Is there any workaround that i can open file read other sheets that don't have charts in them
Sorry, For now we don't parse charts.