Reputation: 604
I am reading xlsx file using OpenXML SDK. There is no issue while reading shared string values but I don't know how to distinguish the actual numbers from the dates as both of them have DataType of null and they are stored as number.
Using DateTime.FromOADate() I can convert numberic value into date format but first I need to identify whether cell format is date or not, otherwise number/currency formatted cell value would also get converted into date.
I tried solution mentioned in this post How to distinguish inline numbers from OLE Automation date numbers in OpenXML SpreadSheet?. but it is not working for currency format,number format (negative number formatting please see attached screenshot) and some custom formats number and currency format screenshot.It would convert currency and number formats into date
I am looking for
Generic solution to distinguish date from all other numeric formats so that all the build in formats (like number,currency,Scientific) and custom formatted numeric values would not be converted into date
Is there generic way to format cell values as per formatting applied in excel sheet.Right now we are handling each formatting separately
Upvotes: 1
Views: 1586
Reputation: 69
Each cell has 2 properties r (CellReference) and s(StyleIndex)
StyleIndex for numbers is 2 and for date is 3
33938
Upvotes: 2