Date format issue dd/mm/yyyy
See original GitHub issueWe are using sheetjs for exporting report which having date coulmns in dd/mm/yyyy format. The exported file converts the date to to mm/dd/yyyy format for those date are less than 13 and other dates are exported as desired. We need to export file with dd/mm/yyyy format itself
How to fix this issue? Or what is the way to disable autoformatting of date column and consider it as string itself?
Sample Code as follows:
<table id="table">
<tr>
<td>1</td>
<td>05/04/2021</td>
<td>Fifth April, Monday</td>
</tr>
<tr>
<td>2</td>
<td>06/04/2021</td>
<td>Sixth April, Monday</td>
</tr>
<tr>
<td>3</td>
<td>11/04/2021</td>
<td>Eleventh April, Sunday</td>
</tr>
<tr>
<td>4</td>
<td>12/04/2021</td>
<td>Twelvth April, Monday</td>
</tr>
<tr>
<td>5</td>
<td>13/04/2021</td>
<td>Thirtheenth April, Monday</td>
</tr>
<tr>
<td>6</td>
<td>14/04/2021</td>
<td>Fourtheenth April, Monday</td>
</tr>
</table>
var wb = XLSX.utils.table_to_book(document.getElementById('table'));
XLSX.writeFile(wb, "sample.xlsx");
Sample JSFiddle is here
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Cant set date to DD/MM/YYYY only DD-MM-YYYY available
I need to set a date to date format DD/MM/YYYY (forward slash) but my Excel 2016 only shows this date format with a...
Read more >Date format issue - dd/mm/yyyy | MrExcel Message Board
I change all date values to dd/mm/yyyy format. But every time another user opens it, the format becomes d/m/yyyy. I prefer dd/mm/yyyy so...
Read more >Excel format text as date (dd mm yyyy format ) #shorts - YouTube
Learn how to fix dates that are in the wrong format. Follow this video to see how to change the date format from...
Read more >Can no longer format date as dd/mm/yyyy in Excel (Office 365)
I have just noticed that appear to no longer be able to format the date as dd/mm/yyyy in Excel (Office 365)
Read more >Date Format "dd/MM/yyyy" Goes Wrong While Writing in Excel
Also what I realized, it only does this error while there is 01 in the date. So today is 02/01/2020 according to my...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There are a few issues here:
@mpsbhat is asking about parsing of ambiguous dates. It is unclear whether “2/1/21” represents “January 02” or “February 01”. There are two workarounds:
A) If you want to bypass value parsing entirely, pass
raw: true
totable_to_book
:B) If you are generating the HTML table, you can add
t
,v
,z
attributes to theTD
element. If the DOM walker sees those attributes, it will use them in lieu of parsing the text. For dates you would sett="d"
and setv
to the ISO8601 string of the date you want.@nivb52 If you have full control over what value you pass, you can actually pass cell objects like
{t:"n", v:45544, z:"m/d/yy"}
instead of the raw date codes. The writers will use the specified number format and Excel will treat them like dates.@Triyank passing
raw: true
will disable date parsingi have some issue, is there any way someone can help? i am uploading an excel and xlsx.read is converting date in my excel In Date(); format of JS but I dont want that i want this has to be treated as string. no conversion in Date object. any suggestions?