Hi,
I m using Infragistics3 Excel ver9, trying to load a workbook/worksheet into a datatable. I found out that a cell that has cell format as custom Date, after loading into the Infragistics cell, it displayed as Double and the value is disorted. I also tried to change the Infragistics cell format to empty or General, but the value still is distorted as double.
How can i get the exact value as stored in MS Excel which has custom format ?
In the Excel format, dates are stored internally in workbooks as numbers. So when a workbook is loaded, that's how the value will appear on the cell. If you know a cell is supposed to be a date, you can convert the value with a static method on Infragistics.Excel.CalcEngine.ExcelCalcValue called ExcelDateToDateTime.
thanks, but the problem is I will not know which cell is gonna be a date, it can be dynamic depends on the excel file is loaded. What else can I do to overcome this ambiguous cell type?
thanks
You can submit a feature request to DS for us to auto-parse the value into it's correct type based on the format string. Other than that, I recommend reading the format string property of the cell. If it is a common date format string, use the conversion method.
I can try to workaround that with manual convert the cell back to date value by detecting the format string.
Besides, is there any ready built class from infragistics to Import Excel file into datatable/dataset ?
Thanks
I have the same problem too: "How understand if a cell contain a Date" ?
The only solution I could implement so far is to custom parsing the CellFormat.FormatString property of the cell; although this is a very ugly workaround, that's the only one I saw.
Any better suggestions?Thanks in advance
Gianni
I see, ok I will try to workaround it and maybe will come back with question later.
No, any import into a data structure must be done manually. I don't think it would be possible for automatic support like this anyway, because those data sources are row-based and the Excel grid is cell-based.