المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : c# excel date issue



C# Programming
08-24-2009, 09:51 AM
Hi ..
I am stuck with issue & don’t seem to find a way around.

I have an excel sheet which I am reading in my C# windows application . I read values form F column to V column. I collect this in a string array & then display the values of the array to user.
The problem is in differentiating the dates & the number values .. here is the problem I faced:
I have 2 cells ..1st one has value 40524 & the 2nd has 12/12/2010. When I get the values both of them are returned as 40524 !! So how do you determine programmatically which cell actually was meant for numbers & which was for date because if I have to display the contents of a row (without knowing the format) I want to show 12/12/2010 as 12/12/2010 & not as 40524.

I am using the following code to get values from Excel

Range vrange = worksheet.get_Range("F" + i.ToString(), "V" + i.ToString());
System.Array vmyvalues = (System.Array)vrange.Cells.Value2;
string [] ret = ConvertToStringArray(vmyvalues);


As you can see i am getting values from column F to V & when I iterate through the above string array "ret" I can see the value as of 12/12/2010 as 40524 where as I need it as is shown by excel

Thanks for help.
Suunil