We are trying to convert some XLS/XLSX files to a pipe separated file.
- Code: Select all
worksheet.SaveToFile(fileExtractPath, "|");
One test file (attached) has a column of dates with Excel format "yyyy-mm-dd h:mm", however when the file is saved to the text file it comes out as, for example, "5/04/2015 5:47:00 AM".
I have found a workaround in setting the Thread's culture prior to export:
- Code: Select all
CultureInfo culture = (CultureInfo)threadCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd HH:mm";
culture.DateTimeFormat.LongTimePattern = "";
Thread.CurrentThread.CurrentCulture = culture;
However, it would be much more preferable to output each cell in the format defined for that cell, rather than applying the same format to the entire spreadsheet.