rainabba / jquery-table2excel

jQuery Plugin to export HTML tabled to Excel Spreadsheet Compatible Files
592 stars 665 forks source link

about date format problem #96

Open zhoubohao0504 opened 6 years ago

zhoubohao0504 commented 6 years ago

I tried to export a date, for example, 2018-02, when I opened the export file, I found that the date format was Feb-18.

ketan365 commented 4 years ago

I have same issue in html to excel date like 19-Dec-2020 or 25-Nov-1999 in excel i get output 19-Dec-20 or 25-Nov-99. In case of 19-Dec-1899 , I get output 19-Dec-1899 it's perfect . Please help me

rainabba commented 4 years ago

Unless a cell's format is explicitly set, it will do its best to auto detect the contents. I think we would need to mark a cell with another attribute to indicate its data type, then just assign that data type to the cell.

I'm thinking "data-type" for the attribute name and the value should reflect a valid option from Excel data types allowed in the XLSX format ( https://docs.microsoft.com/en-us/office/client-developer/excel/data-types-used-by-excel .)

We should check for the existence of this field on the field itself and its ancestors up to the table element so that the data type can be defined as high as the table or as low as a specific cell and inherit to all cells below that which do not have a declared data type.

I'll leave this open for discussion for a couple days to see if anybody wants to provide feedback or take the PR for it and after that discussion, if nobody else has I will.