Hi, when I use
row.GetCellValue(column.Index).ToString()I get number value but in excel column I have date value :(.In excel file the cell format is date and I see value in date format (dd.mm.yyyy).
In my case in the excel sheet I have value 21.2.2002 (dd.mm.yyyy) and row.GetCellValue(column.Index).ToString() returns value 37308.
Could you advise how to get correct date value?
Thank youLibor
I tried to find cell format out.
And here is my list of CellFormat properties. No information regarding date format :(
?column.CellFormat{Infragistics.Documents.Excel.WorksheetColumnOwnedFormatProxy} [Infragistics.Documents.Excel.WorksheetColumnOwnedFormatProxy]: {Infragistics.Documents.Excel.WorksheetColumnOwnedFormatProxy} Alignment: Default BottomBorderColor: "{Name=0, ARGB=(0, 0, 0, 0)}" BottomBorderColorInfo: null BottomBorderStyle: Default DiagonalBorderColor: "{Name=0, ARGB=(0, 0, 0, 0)}" DiagonalBorderColorInfo: null DiagonalBorders: Default DiagonalBorderStyle: Default Fill: null FillPattern: Default FillPatternBackgroundColor: "{Name=0, ARGB=(0, 0, 0, 0)}" FillPatternForegroundColor: "{Name=0, ARGB=(0, 0, 0, 0)}" Font: {Infragistics.Documents.Excel.WorkbookFontOwnerAccessor} FormatOptions: None FormatString: null Indent: -1 LeftBorderColor: "{Name=0, ARGB=(0, 0, 0, 0)}" LeftBorderColorInfo: null LeftBorderStyle: Default Locked: Default RightBorderColor: "{Name=0, ARGB=(0, 0, 0, 0)}" RightBorderColorInfo: null RightBorderStyle: Default Rotation: -1 ShrinkToFit: Default Style: Built in style: Normal TopBorderColor: "{Name=0, ARGB=(0, 0, 0, 0)}" TopBorderColorInfo: null TopBorderStyle: Default VerticalAlignment: Default WrapText: Default
Dates are actually stored in an Excel file as numbers. It is the cell's format string which then displays it as a date. If you are using version 12.1, there is a new GetText() method on the cell which you can use. This will combine the data with the format string to produce the value displayed to the user in Excel.
Also, my guess is that the date format is actually stored on the column, not the cell. If you use the GetResolvedCellFormat() method on the cell, you will probably see a FormatString with a date format.