Cannot determine if the cell value is a number or a date

Oct 22, 2013 at 10:01 AM

I am trying to get the value from an ICell which is the same as what is seen in the spreadsheet.

The problem is I can see no way of telling if the cell is a date or a number????

NOTE: I was using the CellStyle.DataFormat but I cannot find any info on this and it seems to be arbitrary.

Here is the code I have so far...

case CellType.BOOLEAN:
    cellValue = cell.BooleanCellValue.ToString();
case CellType.FORMULA:
    cellValue = cell.CellFormula;
case CellType.NUMERIC:
    cellValue = cell.NumericCellValue.ToString();
    // Excel stores dates as numeric values so check format and convert
    if (IsDateFormat(cell.CellStyle.DataFormat))
        cellValue = DateTime.FromOADate(cell.NumericCellValue)
case CellType.STRING:
case CellType.Unknown:
    cellValue = cell.StringCellValue;
Oct 22, 2013 at 10:03 AM
In case the above is not clear I am looking for how to implement my IsDateFormat(...) method.