Saving to CSV in Excel loses regional date format

前端 未结 8 1835
北海茫月
北海茫月 2020-12-17 15:59

I have a .xls I need to convert to .csv

The file contains some date columns. The format on the date is \"*14/03/2001\" which, according to Excel means the date respo

相关标签:
8条回答
  • 2020-12-17 16:06

    Although keeping this in mind http://xkcd.com/1179/

    In the end I decided to use the format YYYYMMDD in all CSV files, which doesn't convert to date in Excel, but can be read by all our applications correctly.

    0 讨论(0)
  • 2020-12-17 16:07

    Place an apostrophe in front of the date and it should export in the correct format. Just found it out for myself, I found this thread searching for an answer.

    0 讨论(0)
  • 2020-12-17 16:09

    A not so scalable fix that I used for this is to copy the data to a plain text editor, convert the cells to text and then copy the data back to the spreadsheet.

    0 讨论(0)
  • 2020-12-17 16:12

    Change the date and time settings for your computer in the "short date" format under calendar settings. This will change the format for everything yyyy-mm-dd or however you want it to display; but remember it will look like that even for files saved on your computer.

    At least it works.

    0 讨论(0)
  • 2020-12-17 16:16

    Change the date range to "General" format and save the workbook once, and change them back to date format (eg, numberformat = "d/m/yyyy") before save & close the book. savechanges parameter is true.

    0 讨论(0)
  • 2020-12-17 16:25

    You need to do a lot more work than 1. click export 2. Open file.

    I think that when the Excel CSV documentation talks about OS and regional settings being interpreted, that means that Excel will do that when it opens the file (which is in their "special" csv format). See this article, "Excel formatting and features are not transferred to other file formats"

    Also, Excel is actually storing a number, and converting to a date string only for display. When it exports to CSV, it is converting it to a different date string. If you want that date string to be non-default, you will need to convert your Excel cells to strings before performing your export.

    Alternately, you could convert your dates to the number value that Excel is saving. Since that is a time code, it actually will obey OS and regional settings, assuming you import it properly. Notepad will only show you the 10-digit number, though.

    0 讨论(0)
提交回复
热议问题