I am busy developing a component which imports data from a MS Excel (2016) file. This component uses the MS OpenXML SDK2.5 library. The end-users installation of MS Excel is based on Dutch country / region settings. The file contains, among others, a column with financial data (numeric). The position of this column is not known in advance.
To determine if a cell contains numeric data I evaluate the property Cell.DataType (of type CellValues, which is an enum). At first it seems that this property is the perfect candidate to determine this. Possible values of CellValues are: Boolean, Number, Error, SharedString, String, InlineString or Date. So I would expect that Cell.DataType is set to CellValues.Number. After some debugging I found out that Cell.DataType is null when the cell contains numeric data.
While searching on internet to find an explanation I found the following MSDN article: https://msdn.microsoft.com/en-us/library/office/hh298534.aspx
The article describes exactly what I found during debugging:
The Cell type provides a DataType property that indicates the type of the data within the cell. The value of the DataType property is null for numeric and date types.
Does anybody know why Cell.DataType is not initialized with respectively CellValues.Number or CellValues.Date?
What is the best way to determine if a cell contains a numeric value?