Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
[0.15.1] Text being converted to dates #1636
Comments
|
May I request a question , whether the js-xlsx can show the excel datas use the format of "yyyy.m.d h:mm" not the "yyyy.m.d h:mm" to text format,when I used the js-xlsx , the "2019.9.22 16:22" was convert to "43730.682291666664",I want to add the datetime like "2019.9.22 16:22" to as ECharts'xaxis. I am sorry my english is poor ,very sorry... if you can answer my ,I will very very happy!! |
|
Pretty sure that's what the cellDates parse option is all about, but please move discussion for this elsewhere as it's unrelated to this issue. |
|
I am sorry, because I see your issue is relate to dates,so I want to request you... I am sorry to disturb you.. thank you for your answer. |
|
Related to this issue, I'm seeing this text: |
|
All of these issues are related to date parsing. @Webifi that is a good fix and we'll accept a PR for more restrictive date testing. @CNzxy0820 to export a date using a specific format, set the "z" property of the cell to the desired format: ws["A1"].z = 'yyyy"."m"."d h:mm'; // 2020.6.27 13:37
ws["A1"].z = 'yyyy"."mm"."dd hh:mm'; // 2020.06.27 13:37@datermine related to dates but not related to this specific issue. The text "76.09" is parsed as a date (1976-09-01) but is not recognized as a number because of the prefix "AUD " |
|
Hi @SheetJSDev, I would like to work on this issue. From the discussion, I think we wish to have more robust pattern checking before parsing a cell as Date.
I think it should be fine. But it doesn't take care of
It will check for types like |
When exporting a table with table_to_book, a cell with a text value of "Smith, Julie + 5" is being converted to "07/05/2001". {raw: true} fixes this, but then columns with actual dates are not being converted.
Edit:
Looks like the issue is with the fuzzydate method.
While it won't fix everything (fuzzydate is way too, well, fuzzy), changing:
if(s.toLowerCase().match(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/)) return o;to:
if(s.match(/\b(jan(\b|uary\b)|feb(\b|ruary\b)|mar(\b|ch\b)|apr(\b|il\b)|may\b|jun(\b|e\b)|jul(\b|y\b)|aug(\b|ust\b)|sep(\b|tember\b)|oct(\b|ober\b)|nov(\b|ember\b)|dec(\b|ember\b))(\s*|\/|-)[0-9]+/i)) return o;if(s.match(/[0-9]+(\b|st|th|\/|-)\s*\b(jan(\b|uary\b)|feb(\b|ruary\b)|mar(\b|ch\b)|apr(\b|il\b)|may\b|jun(\b|e\b)|jul(\b|y\b)|aug(\b|ust\b)|sep(\b|tember\b)|oct(\b|ober\b)|nov(\b|ember\b)|dec(\b|ember\b))/i)) return o;would at least make the month match more restrictive.
Currently it looks like fuzzydate would match a date on text like "... You may need 5 ..." or "julie is missing 5 teeth" or "6 children marching" or even "I fear lauging clowns".
The updated regexps would require "may 5" or "jul 5" or "july 5th" or "6 march" (abbreviated or full month followed by a number or number (+optional ordinal) followed by month)