Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.6k
stars
787
forks
source link
syncfusion_flutter_xlsio dateTime format gives wrong information #2179
When trying to set the DateTime format for chart (X axis) it doesn't work.
When i set numberFormat for individual cell like this:
sheet.getRangeByName('A2').numberFormat = 'dd-MM-yyyy'; it display number like this: 2.65465456757454
When i set the DateTime format like this:
chart.primaryCategoryAxis.numberFormat = 'dd-MM-yyyy'; It display wrong date example for DateTime(2014, 01, 14, 14, 14, 14) it display 04-05-1900
Bug description
When trying to set the DateTime format for chart (X axis) it doesn't work.
When i set numberFormat for individual cell like this:
sheet.getRangeByName('A2').numberFormat = 'dd-MM-yyyy';
it display number like this: 2.65465456757454When i set the DateTime format like this:
chart.primaryCategoryAxis.numberFormat = 'dd-MM-yyyy';
It display wrong date example forDateTime(2014, 01, 14, 14, 14, 14)
it display04-05-1900
Steps to reproduce
Code sample
Code sample
```dart final Workbook workbook = Workbook(); final Worksheet sheet = workbook.worksheets[0]; sheet.getRangeByName('A1').setText('Months'); sheet.getRangeByName('B1').setText('Internal Sales Amount'); sheet.getRangeByName('C1').setText('Reseller Sales Amount'); sheet.getRangeByName('A2').setDateTime(DateTime(2014, 01, 14, 14, 14, 14)); sheet.getRangeByName('A2').numberFormat = 'dd-MM-yyyy'; // When trying this it gives number example: 2.65465456757454 sheet.getRangeByName('A3').setDateTime(DateTime(2014, 02, 14, 14, 14, 14)); sheet.getRangeByName('A3').numberFormat = 'dd-MM-yyyy'; sheet.getRangeByName('A4').setDateTime(DateTime(2014, 03, 14, 14, 14, 14)); sheet.getRangeByName('A4').numberFormat = 'dd-MM-yyyy'; sheet.getRangeByName('A5').setDateTime(DateTime(2014, 04, 14, 14, 14, 14)); sheet.getRangeByName('A5').numberFormat = 'dd-MM-yyyy'; sheet.getRangeByName('A6').setDateTime(DateTime(2014, 05, 14, 14, 14, 14)); sheet.getRangeByName('A6').numberFormat = 'dd-MM-yyyy'; sheet.getRangeByName('B2').setNumber(700); sheet.getRangeByName('B3').setNumber(200); sheet.getRangeByName('B4').setNumber(300); sheet.getRangeByName('B5').setNumber(500); sheet.getRangeByName('B6').setNumber(800); sheet.getRangeByName('C2').setNumber(30); sheet.getRangeByName('C3').setNumber(40); sheet.getRangeByName('C4').setNumber(70); sheet.getRangeByName('C5').setNumber(2); sheet.getRangeByName('C6').setNumber(100); final ChartCollection charts = ChartCollection(sheet); final Chart chart = charts.add(); chart.primaryCategoryAxis.numberFormat = 'dd-MM-yyyy'; // When trying this it gives wrong Date: example 01-01-1900 chart.chartType = ExcelChartType.line; chart.dataRange = sheet.getRangeByName('A1:C6'); chart.isSeriesInRows = false; chart.chartTitle = 'Yearly sales'; chart.chartTitleArea.bold = true; chart.chartTitleArea.size = 12; chart.legend?.position = ExcelLegendPosition.bottom; chart.topRow = 0; chart.bottomRow = 20; chart.leftColumn = 1; chart.rightColumn = 8; chart.primaryValueAxis.numberFormat = '0.00'; final ChartSerie serie = chart.series[0]; serie.dataLabels.isValue = true; serie.dataLabels.isCategoryName = true; serie.dataLabels.isSeriesName = true; serie.dataLabels.textArea.bold = true; serie.dataLabels.textArea.size = 12; serie.dataLabels.textArea.fontName = 'Arial'; sheet.charts = charts; ListScreenshots or Video
Screenshots / Video demonstration
[Upload media here] ![WhatsApp Image 2024-11-20 at 15 54 42](https://github.com/user-attachments/assets/c53fc60b-8961-4cbb-9357-b5114f9fdf83) ![WhatsApp Image 2024-11-20 at 15 54 21](https://github.com/user-attachments/assets/d74e6817-26ad-483b-b8f4-4b15f4a144a2)Stack Traces
Stack Traces
```dart No stack trace: it just return a wrong data ```On which target platforms have you observed this bug?
iOS
Flutter Doctor output
Doctor output
```console [✓] Flutter (Channel stable, 3.24.3, on macOS 15.1 24B83 darwin-arm64, locale en-MA) • Flutter version 3.24.3 on channel stable at /Users/mymac/Development/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 2663184aa7 (2 months ago), 2024-09-11 16:27:48 -0500 • Engine revision 36335019a8 • Dart version 3.5.3 • DevTools version 2.37.3 [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/mymac/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/mymac/Library/Android/sdk • Java binary at: /Library/Java/JavaVirtualMachines/openjdk-17.jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment Homebrew (build 17.0.12+0) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 16.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 16B40 • CocoaPods version 1.15.2 [✓] Android Studio (version 2024.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11) [✓] VS Code (version 1.95.3) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.100.0 [✓] Connected device (2 available) • iPhone (mobile) • 00008130-000468313A46001C • ios • iOS 18.1 22B83 • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.1 24B83 darwin-arm64 [✓] Network resources • All expected network resources are available. • No issues found!```