question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExcelDataReader.GetNumberFormatString returns wrong value

See original GitHub issue

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:

excel

In Code it returns d/m/yyyy:

code

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:16

github_iconTop GitHub Comments

2reactions
appel1commented, Jul 2, 2021

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.

1reaction
appel1commented, Jul 2, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to keep the datetimeformat of excel.cell into dataset cell
ExcelDataReader loses Excel's formatting information when using AsDataSet() , which basically gives you only the raw values.
Read more >
LinRaise/ExcelDataReader
GetNumberFormatString () returns a string containing the formatting codes for a value in the current row, or null if there is no value....
Read more >
ExcelDataReader
GetNumberFormatString () returns a string containing the formatting codes for a value in the current row, or null if there is no value....
Read more >
How to read excel data with formatted values in C#... - ...
GetValue(columnIndex); var formatString = reader.GetNumberFormatString(columnIndex); if (formatString == null) return Convert.ToString(value ...
Read more >
ExcelDataReader
ExcelDataReader.GetNumberFormatString returns wrong value $ 0. Created 3 years ago in ExcelDataReader/ExcelDataReader with 16 comments. When reading the format ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found