ExcelDataReader: ExcelDataReader.GetNumberFormatString returns wrong value
When reading the format of a cell with Short Date Format, Excel returns the format according to the system configuration, but GetNumberFormatString returns always as “d/m/yyyy”
In Excel it says m/d/yyyy:
In Code it returns d/m/yyyy:
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 16
It can be done, but it requires work. LinqToExcel simply uses Excel itself to do the work via its OLEDB provider.
ExcelDataReader is completely standalone and does not rely on Excel.
I think recent versions of Excel only ever uses a built-in format 14, at least for western locales, in all other cases it explicitly includes the format string in the file. So it depends on what the source is for the files you want to validate and how thorough you want to be.
14 as far as I know matches the short date format in Windows.
If you need to handle more cases then look at BuiltinNumberFormat.cs to try and figure out what the culture specific variant of the built-in format index is, I believe the hardcoded ones there are en-us. If you also need to support Asian cultures then look at #541 where we’ve started to figure that stuff out.
You can do what andersnm described and look at the result from GetNumberFormatIndex.