Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncfusion_flutter_xlsio dateTime format gives wrong information #2179

Open
Errechydy opened this issue Nov 20, 2024 · 0 comments
Open

syncfusion_flutter_xlsio dateTime format gives wrong information #2179

Errechydy opened this issue Nov 20, 2024 · 0 comments
Labels
open Open xlsIO XlsIO component

Comments

@Errechydy
Copy link

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.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

Steps to reproduce

  • Try to export chart in the following code sample

Code sample

Code sample
    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;
    List<int> bytes = workbook.saveAsStream();
    File('ChartElement.xlsx').writeAsBytes(bytes);
    workbook.dispose();

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]
WhatsApp Image 2024-11-20 at 15 54 42
WhatsApp Image 2024-11-20 at 15 54 21

Stack Traces

Stack Traces
No stack trace: it just return a wrong data

On which target platforms have you observed this bug?

iOS

Flutter Doctor output

Doctor output
[✓] 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!```

</details>
@VijayakumarMariappan VijayakumarMariappan added xlsIO XlsIO component open Open labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open Open xlsIO XlsIO component
Projects
None yet
Development

No branches or pull requests

2 participants