excel icon indicating copy to clipboard operation
excel copied to clipboard

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

Open marcellocamara opened this issue 1 year ago • 1 comments

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 avatar May 06 '24 23:05 marcellocamara

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

marcellocamara avatar May 08 '24 02:05 marcellocamara