You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SCENARIO: our reactjs app has an option to export the same data source as .CSV file or as a .XLSX file. Data source (JSON array) is identical in both cases and the same method is doing the export logic for both file types.
Before a file is finally exported, I'm formatting certain columns based on the settings provided, such that I'm setting certain columns' formats to type DATE with a specific date formatting style - so something like this =>
where dateCellFormat is => const dateCellFormat = 'm/d/yy';
ISSUE: when saving a file as .XLSX file then date formatting is correctly applied to cells that I'm targeting, but when saving that same data source as .CSV it is not.
In the case of .XLSX file, when I open it in excel, it says that the cell's format is of type DATE (with m/d/yy formatting applied correctly), so that works as intended, but when I open the .CSV export in excel, then it says that the cell's format is of type CUSTOM (with m/d/yyyy h:mm formatting applied, which seems like a bug to me since nowhere in code am I applying such formatting).
Once again, json data source is the SAME for both file types and the same method is doing the export logic for both file types.
QUESTION: is there something that I'm missing ? Should I format cells in some different fashion when exporting to .csv or did I just find a bug ?
The text was updated successfully, but these errors were encountered:
IGrobenskiTT
changed the title
Cell Date format issue when saving a file as CSV
Cells' Date format issue when saving a file as CSV
Feb 4, 2022
It generates both the XLSX and the CSV file. Opening the CSV file looks like:
Thanks to your comment now I see what I forgot to outline in my original post, the cell's v (value) is not of type Date , but actually, a string containing a date. And that's where the bug happens.
So if you cast it to Date, and set the cell's value to that, then it works in both file types, but if you pass Date formatted as a string, then your code only works in XLS, but not in CSV . This is confusing, at least, if a certain cell formatting logic works in xls , it should work in csv as well, right ? Thanks for your feedback once again
I updated your fiddle so that you can see what I'm talking about (you'll see that it displays as intended in xls file, but not in csv file) : https://jsfiddle.net/4xfuL9rz/
SCENARIO: our reactjs app has an option to export the same data source as .CSV file or as a .XLSX file. Data source (JSON array) is identical in both cases and the same method is doing the export logic for both file types.
Before a file is finally exported, I'm formatting certain columns based on the settings provided, such that I'm setting certain columns' formats to type DATE with a specific date formatting style - so something like this =>
where
dateCellFormat
is =>const dateCellFormat = 'm/d/yy';
ISSUE: when saving a file as .XLSX file then date formatting is correctly applied to cells that I'm targeting, but when saving that same data source as .CSV it is not.
In the case of .XLSX file, when I open it in excel, it says that the cell's format is of type DATE (with m/d/yy formatting applied correctly), so that works as intended, but when I open the .CSV export in excel, then it says that the cell's format is of type CUSTOM (with m/d/yyyy h:mm formatting applied, which seems like a bug to me since nowhere in code am I applying such formatting).
Once again, json data source is the SAME for both file types and the same method is doing the export logic for both file types.
QUESTION: is there something that I'm missing ? Should I format cells in some different fashion when exporting to .csv or did I just find a bug ?
The text was updated successfully, but these errors were encountered: