Giter Site home page Giter Site logo

Comments (19)

nipunasudha avatar nipunasudha commented on August 14, 2024 4

I found out about a workaround until this is officially fixed. Please take a look at this article that explains that number means. You can write a simple function to convert this number into a DateTime.

How Dates Work in Excel – The Calendar System Explained + Video

Each Day is a Whole Number
Each day is represented by one whole number in Excel. Type a 1 in any cell and then format it as a date. You will get 1/1/1900. The first day of the calendar system.

Type a 2 in a cell and format it as a date. You will get 1/2/1900, or January 2nd. This means that one whole day is
represented by one whole number is Excel.
You can also take a cell that contains a date and format it as a number.

For example, this post was published on 1/27/2016. Put that number in a cell (the keyboard shortcut to enter today's date is Ctrl+;), and then format it as a number or General.
You will see the number 42,396. This is the number of days that have elapsed since 1/1/1900.

from excel.

BugsBuggy avatar BugsBuggy commented on August 14, 2024 3

Here's a simple static util method I use to convert excel dates to DateTime. Hope this helps :)

  import 'package:jiffy/jiffy.dart';

  static DateTime tryParseExcelDateTimeDouble(double dateDouble, {DateTime ifInvalid}) {
    if (dateDouble == null || dateDouble < 1) return ifInvalid;
    return Jiffy(DateTime(1900, 1, 1))
        .add(days: dateDouble.toInt() - 1)
        .dateTime;
  }

It'll work if you change dateDouble.toInt() - 1 to dateDouble.toInt() - 2

from excel.

ashishbeck avatar ashishbeck commented on August 14, 2024 1

Also, the date value that we receive is not consistent. The CellTypes are either string or integer and it is pretty random as you can see here. It makes it very difficult to identify if a cell is an integer or date in disguise. For a sheet with a predetermined date column, it would be easy to convert them to DateTime depending on its type (string or int) but not for a generalized sheet. It would be great if you could also introduce a new CellType.date and return an actual DateTime object instead of a string/int.

from excel.

ashishbeck avatar ashishbeck commented on August 14, 2024 1

Of course, it must be a stress for you to dedicate to things outside of work and we are really grateful for it. All I can hope for is you to push fixes whenever possible.

from excel.

nipunasudha avatar nipunasudha commented on August 14, 2024 1

Here's a simple static util method I use to convert excel dates to DateTime. Hope this helps :)

  import 'package:jiffy/jiffy.dart';

  static DateTime tryParseExcelDateTimeDouble(double dateDouble, {DateTime ifInvalid}) {
    if (dateDouble == null || dateDouble < 1) return ifInvalid;
    return Jiffy(DateTime(1900, 1, 1))
        .add(days: dateDouble.toInt() - 1)
        .dateTime;
  }

from excel.

justkawal avatar justkawal commented on August 14, 2024

Started working on this in beta (unstable) branch :: https://github.com/kawal7415/excel/tree/beta

As we had started to work on providing Formula functionality, So we will be providing various CellType support.

Thank You
Stay Tuned...
Long Live Open S🔥urce

from excel.

st99 avatar st99 commented on August 14, 2024

Is there a solution for this problem.
I still am not able to recieve fields as date.

Excel only recieves the fields as date if it is in the first column. For columns other than that, I get values such as 43959.

from excel.

yunior123 avatar yunior123 commented on August 14, 2024

Hello, how do I receive the fields as Date?
I have a column with the fields as Date but when I order to display some numbers appear.
For example the date in the file is: 08/05/2020 12:00:00
No Flutter in print (as your example) appears: 43959.5
How to solve?

Hello, did you manage to solve this issue?

from excel.

yunior123 avatar yunior123 commented on August 14, 2024

I am having the same issue indicated above

from excel.

sleepingkit avatar sleepingkit commented on August 14, 2024

Same issue.

from excel.

ashishbeck avatar ashishbeck commented on August 14, 2024

Or you could simply return the default string value as it appears on the Excel (dd-mm-yyyy) and let us parse it. That would be really simple and easy.

from excel.

justkawal avatar justkawal commented on August 14, 2024

@ashishbeck
Structure of excel doesn't support to have normal date as String, If I would have done that way then the excel file would have easily broken on Google Sheets,, Sheets from the Apple software and also on Microsoft Excel.

I thinks that the answer from @nipunasudha would be promising to help you out in this scenario until I push a fix for it.

from excel.

Bes79 avatar Bes79 commented on August 14, 2024

Awaiting for DateTime column )

from excel.

MalikSamiAwan avatar MalikSamiAwan commented on August 14, 2024

@nipunasudha your solution worked for me THANKS with just small issue its showing me one day ahead. Is that a big problem or should i manually add 1 day to it.

from excel.

joe-mybuzz avatar joe-mybuzz commented on August 14, 2024

Is there a way to set a cell as a Date when exporting Excel?

from excel.

MalikSamiAwan avatar MalikSamiAwan commented on August 14, 2024

@BugsBuggy and how can we store date values?

from excel.

Bes79 avatar Bes79 commented on August 14, 2024

Any news?

from excel.

quaaantumdev avatar quaaantumdev commented on August 14, 2024

I implemented the support for date, time and date-time values, here is the PR: #279
And so you may also use it like this as long as it is not available in the main branch:

# pubspec.yaml

dependencies:
  excel
    git: https://github.com/quaaantumdev/excel.git

( the repository may be deleted once the changes are merged )

from excel.

justkawal avatar justkawal commented on August 14, 2024

Can you try version:

excel: ^4.0.0

from excel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.