EXCEL CELL CUSTOM FORMAT hhmmss
-
Monday, August 06, 2012 2:54 PMHi There
I am reading data from a excel sheet using a c# console application
in the excel sheet I got a cell c which is format to hhmmss(custome format) and the a value of 110000
but when I ready this from c# it reads as 0.458333333
how do I overcome this issue
thanks for all you help and assistant
I am using c# to in my console application
Thanks
All Replies
-
Monday, August 06, 2012 3:06 PM
Excel stores dates and times as numbers, with 1 day (24 hours) as unit.
So 11:00:00 is stored as 11/24 = 0.458333... - the value that you're getting. If you want to perform calculations with the time, you should be able to use the value 0.458333...
If you want to retrieve the value as displayed on the screen (110000), use the Text property of the cell instead of the Value property.
Regards, Hans Vogelaar
-
Monday, August 06, 2012 3:21 PM
Sorry I think I did not explain to right
I do I get the text property ?If I give you a part of my code what I am readying is
private static DateTime? ReadTimeCell(OleDbDataReader dr, int cellNo)DateTime dt = DateTime.Today;
dt.AddHours(dr[cellNo])the dr is the excel data row and cell no is the 2 for referring cell C
-
Monday, August 06, 2012 3:55 PMSorry, I don't know C#, so I can't help with that.
Regards, Hans Vogelaar
-
Monday, August 06, 2012 7:04 PM
If you pass an integer cast of "24*dr[cellNo]" to the AddHours routine I would think it'll do what you want:
dt.AddHours( (int)(24*dr[cellNo]) );
- Marked As Answer by Rushdy Najath Tuesday, August 07, 2012 9:42 AM

