Date support #17
Labels
No Label
DBF
Dates
Defined Names
Features
Formula
HTML
Images
Infrastructure
Integration
International
ODS
Operations
Performance
PivotTables
Pro
Protection
Read Bug
SSF
SYLK
Style
Write Bug
good first issue
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sheetjs/sheetjs#17
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I created a simple spreadsheet with a few dates in a few of the cells (ie, "12/01/2012"). It looks like the value (cell.v param) returns a number (it appears to be the number of days since 1/1/1900). Is there anyway that xlsx.js could do this date conversion automatically so that cell.v returns a date string? I know there is date formatting, etc, but even if it's just a M/D/Y date string, that would be great. In the raw sheet xml there is a "s=1" on all of my date cells.
This library is great, BTW - thanks for your work.
@wbrandongeorge sorry for the delay in getting back.
The reason I haven't put in dates yet is because of an excel bug: 1900 was not a leap year, but Excel treats 2/29/1900 as an existing date (Try creating a cell with value 60 and then changing the format to date). I think it may be safe to just assume all date values are beyond 60 (in which case translating is easy) but I held off until someone asked for it :)
If you aren't using dates from 1900 (please confirm that is the case) then I will add JS date parsing.
Interesting bug :) I'm not worried at all about dates from 1900. It would be awesome if you added JS date parsing - thanks again.
@wbrandongeorge I haven't forgotten :) I explored the problem further:
It makes more sense (because it would have to happen at one point) to solve the general problem of processing format codes. That is being developed as a separate module and will be hooked into this module when it is done. Will keep you posted :)
Good to know. The general processing of format codes makes sense. I don't know what your priorities are, but the standard date formats are probably my biggest need. Which do you foresee as more important on your end?
Your focus and progress are exciting. Thanks for your work on this.
I should have the general processing code ready to go (and integrated with
both this and the js-xls project) by Friday afternoon (Good Friday presents
an opportunity to hammer this out :) If you need something sooner I could
put in a quick patch later today.
On Tue, Mar 26, 2013 at 3:54 PM, wbrandongeorge notifications@github.comwrote:
That sounds great. If it's possible to get the standard formats done sooner that would be wonderful. However, I completely understand if you have other priorities you need to address. Thank you.
@wbrandongeorge this should handle the most common date formats. Lemme know if there are any problems
This is fantastic - thanks for such a quick turnaround! One quick question - I created a few dates in a spreadsheet that use forward slashes (ie, "5/10/12"). When parsing the spreadsheet in JS, the string values contain dashes instead (ie, "05-10-12"). Is that expected behavior?
That's definitely not expected. Special characters (like - and /) should be
translated in verbatim.
I'm not in front of a computer at the moment, but can you put up a sample
file somewhere (like on dropbox) and mention how you generated the file
(you would think every generator would use the spec, but I noticed a few
issues with how google docs handles dates -- they don't emit the proper
format code for AM/PM). I have mm/dd/yyyy in my test file and I thought
that generated the correct output.
On Wednesday, March 27, 2013, wbrandongeorge wrote:
Here is a link to the sample file: http://dl.dropbox.com/u/15285248/date_test.xlsx
I created the file with Excel 2011 (Mac). I created three dates in mm/dd/yyyy format. Thanks for looking at it.
@wbrandongeorge the spec is not agreeing with excel on that particular format.
format ID 14 is stated as "mm-dd-yy" (part 1, page 1768) for some strange reason. I'll go with excel on this one
@wbrandongeorge I pushed a change to force it to use the excel format rather than the ecma format. Check it out
Worked great - thanks!
I have a different spreadsheet with some dates that look like they are 4 years off (when read by xlsx.js). I converted a CSV file to XLSX (by just using Save As...) in Excel for Mac. I'm guessing that for some reason that workflow (saving from CSV to XLSX) causes the offset for dates to be 1904 instead of 1900?
If you have a minute to look at it that would be great.
Here is the link to the file on dropbox: http://dl.dropbox.com/u/15285248/date_test2.xlsx
@wbrandongeorge I pushed a new commit. Check the latest version
(it appears that the formatting logic supported the 1904 dates, but the relevant flag from the XLSX sheet wasn't being passed to it)
It looks like date_test2.xlsx works now, but date_test.xlsx does not (here is the file: http://dl.dropbox.com/u/15285248/date_test.xlsx) - these dates now are 4 years too late.
Thanks for working on this.
@wbrandongeorge take a peek
https://www.dropbox.com/s/nduavi5hpmpf40y/date_test_1900.xlsx
https://www.dropbox.com/s/ob44bwwfej256h2/date_test_1904.xlsx
Works like a champ. Thank you!