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.Offic e.Interop.Excel .Workbook theWorkbook
= obj.Workbooks.O pen(file1.FileN ame, 0, true, 5, "", "", false,
Microsoft.Offic e.Interop.Excel .XlPlatform.xlW indows, "\t", false,
false, 0, true, false, false);
Microsoft.Offic e.Interop.Excel .Sheets sheet =
theWorkbook.Wor ksheets;
Microsoft.Offic e.Interop.Excel .Worksheet worksheet =
(Microsoft.Offi ce.Interop.Exce l.Worksheet)she et.get_Item(1);
Microsoft.Offic e.Interop.Excel .Range R;
object[,] val;
R = worksheet.get_R ange("A1", "B1");
val = (object[,])R.Cells.Value2 ;
When I use Datetime conversion like this
Convert.ToDateT ime(((Microsoft .Office.Interop .Excel.Range)wo rksheet.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.Offic e.Interop.Excel .Workbook theWorkbook
= obj.Workbooks.O pen(file1.FileN ame, 0, true, 5, "", "", false,
Microsoft.Offic e.Interop.Excel .XlPlatform.xlW indows, "\t", false,
false, 0, true, false, false);
Microsoft.Offic e.Interop.Excel .Sheets sheet =
theWorkbook.Wor ksheets;
Microsoft.Offic e.Interop.Excel .Worksheet worksheet =
(Microsoft.Offi ce.Interop.Exce l.Worksheet)she et.get_Item(1);
Microsoft.Offic e.Interop.Excel .Range R;
object[,] val;
R = worksheet.get_R ange("A1", "B1");
val = (object[,])R.Cells.Value2 ;
When I use Datetime conversion like this
Convert.ToDateT ime(((Microsoft .Office.Interop .Excel.Range)wo rksheet.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.
Comment