B
Bharathi
Hi,
I got strucked with reading date value from excel file using
C#.NET.
For Jan-2000 the value I am getting is 36526.0.
For all other dates also I am getting some double value like this.
Is there any manipulation so that I can find out the date entered in
excel file.
Excel cell contains date value in the format Mon-YYYY.
I should be able to extract this date as it is.
Please help me...........
Please go through the code snippet:
Microsoft.Office.Interop.Excel.Workbook theWorkbook
= obj.Workbooks.Open(file1.FileName, 0, true, 5, "", "", false,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false,
false, 0, true, false, false);
Microsoft.Office.Interop.Excel.Sheets sheet =
theWorkbook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet worksheet =
(Microsoft.Office.Interop.Excel.Worksheet)sheet.get_Item(1);
Microsoft.Office.Interop.Excel.Range R;
object[,] val;
R = worksheet.get_Range("A1", "B1");
val = (object[,])R.Cells.Value2;
When I use Datetime conversion like this
Convert.ToDateTime(((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1,
3]).Value2)
I am getting a run-time error saying can't convert from double to
datetime.
Please help me...
Thanks in advance,
Bharathi.
I got strucked with reading date value from excel file using
C#.NET.
For Jan-2000 the value I am getting is 36526.0.
For all other dates also I am getting some double value like this.
Is there any manipulation so that I can find out the date entered in
excel file.
Excel cell contains date value in the format Mon-YYYY.
I should be able to extract this date as it is.
Please help me...........
Please go through the code snippet:
Microsoft.Office.Interop.Excel.Workbook theWorkbook
= obj.Workbooks.Open(file1.FileName, 0, true, 5, "", "", false,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false,
false, 0, true, false, false);
Microsoft.Office.Interop.Excel.Sheets sheet =
theWorkbook.Worksheets;
Microsoft.Office.Interop.Excel.Worksheet worksheet =
(Microsoft.Office.Interop.Excel.Worksheet)sheet.get_Item(1);
Microsoft.Office.Interop.Excel.Range R;
object[,] val;
R = worksheet.get_Range("A1", "B1");
val = (object[,])R.Cells.Value2;
When I use Datetime conversion like this
Convert.ToDateTime(((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1,
3]).Value2)
I am getting a run-time error saying can't convert from double to
datetime.
Please help me...
Thanks in advance,
Bharathi.