justkawal / excel

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

Encoding DateTimeCellValue fails #313

Open timobaehr opened 6 months ago

timobaehr commented 6 months ago

If I call Excel.encode on Android with locale German, I'm getting a StandardNumericNumFormat(0, "General") does not work for DateTimeCellValue with stacktrace exception and encoding has failed.

If the CellStyle manually is setting numberFormat, this CellType works.

final CellStyle cellStyleDateTime = CellStyle(fontFamily: getFontFamily(FontFamily.Arial))
  ..numberFormat = NumFormat.defaultDateTime;
DateTimeCellValue(
  year: time.year,
  month: time.month,
  day: time.day,
  hour: time.hour,
  minute: time.minute,
)
..cellStyle = cellStyleDateTime;
ChristopherLinnett commented 5 months ago

Thanks. I'm on en_AU and had the same issue. Noticed it affects DoubleCellValues too, but the same fix applying the default number format.