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

Reading Date values from cell #89

Closed
sourav13 opened this issue Dec 9, 2019 · 8 comments · Fixed by #102
Closed

Reading Date values from cell #89

sourav13 opened this issue Dec 9, 2019 · 8 comments · Fixed by #102
Assignees
Labels
enhancement New feature or request

Comments

@sourav13
Copy link

sourav13 commented Dec 9, 2019

I tried the parsing with sharedStrings and the value of cells directly in case of numbers. Both work fine. But when there is a date in the cell field. It's not returned as String, which I thought it would be. But I get a rather random number 4328 something.

@MaxDesiatov
Copy link
Collaborator

Hi @sourav13, thank you for reporting this. Would you be able to attach this file here or to send it to hello@corexlsx.org if you can't share the file publicly? This way it would be significantly easier to reproduce and fix the issue.

@MaxDesiatov MaxDesiatov added the more info needed Not enough details available to proceed label Dec 9, 2019
@sourav13
Copy link
Author

Dates.xlsx

@sourav13
Copy link
Author

Hello @MaxDesiatov So have you tested it with above file?

@MaxDesiatov MaxDesiatov assigned MaxDesiatov and unassigned sourav13 Dec 16, 2019
@MaxDesiatov MaxDesiatov added documentation Documentation improvements and removed more info needed Not enough details available to proceed labels Dec 16, 2019
@MaxDesiatov
Copy link
Collaborator

Hi @sourav13, these dates are stored in a special "OLE Automation Date" format:

An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899, and whose fractional component represents the time on that day divided by 24. For example, midnight, 31 December 1899 is represented by 1.0; 6 A.M., 1 January 1900 is represented by 2.25; midnight, 29 December 1899 is represented by -1.0; and 6 A.M., 29 December 1899 is represented by -1.25.

For now you can parse these dates by converting the string to a Double or Decimal value and then converting it to a date using an algorithm described above. CoreXLSX will be able to convert those dates for you automatically in a future version and I'll keep this issue open until then.

@MaxDesiatov MaxDesiatov added the enhancement New feature or request label Dec 16, 2019
@sourav13
Copy link
Author

@MaxDesiatov I tried parsing them as strings, If they would have been parsable as strings I would have tried converting them to the desired format but I can't read them as Strings from sharedStrings Model.

@MaxDesiatov
Copy link
Collaborator

These cells don't have type "s" which would indicate their value is stored in sharedStrings, it can be accessed directly from the value property instead.

@jcampana
Copy link

jcampana commented Jan 17, 2020

Hi, waiting for this issue. Any news? Thanks @MaxDesiatov !

@MaxDesiatov MaxDesiatov changed the title Reading Date values from cell. Reading Date values from cell Apr 6, 2020
@MaxDesiatov MaxDesiatov removed the documentation Documentation improvements label Apr 6, 2020
@MaxDesiatov
Copy link
Collaborator

I apologize for the delay. There's a new dateValue property added on the Cell type in #102, hope this resolves the issue.

MaxDesiatov added a commit that referenced this issue Apr 6, 2020
New `stringValue` and `dateValue` helpers on the `Cell` type are added, which allow getting corresponding string (including shared strings) and date values easier.

Resolves #71
Resolves #89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants