justkawal / excel

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

Can't read the XLSX file from http request - Damaged Excel file: Corrupted Excel file #350

Open marcellocamara opened 2 months ago

marcellocamara commented 2 months ago

I can't read this xlsx file, obtained from an http request: https://servicebus2.caixa.gov.br/portaldeloterias/api/resultados/download?modalidade=Mais-Milionaria

Example code:

final response = await get(
  Uri.parse("https://servicebus2.caixa.gov.br/portaldeloterias/api/resultados/download?modalidade=Mais-Milionaria"),
);

if (response.statusCode == 200) {
   final Excel excel = Excel.decodeBytes(response.bodyBytes);

   for (var table in excel.tables.keys) {
      print(table); // Sheet Name
   }
}

It throws the following exception when trying to print the table name: Damaged Excel file: Corrupted Excel file.

marcellocamara commented 2 months ago

I've created an example app: https://github.com/marcellocamara/issues/blob/master/Flutter3Excel/lib/main.dart