Problem Getting DateTime Value

I am working with a sheet, looping through cells and verifying some formatting and other info before I build some insert statements to insert some raw data into our database.

I cannot, in any way, seem to actually get the DATE value put into a cell. It comes out like “375000” instead of “9/1/2003” (which is what was typed in the cell).

I know this is because of the way MS Excel stores values. However, I have the cell’s format property cell to be “m/dd/yyyy” (I set this while using real Excel). I’ve also set this property in my c# code just before I get the value out - no dice!

Any thoughts?

Hi,

You can use the following code to set number format as DATE.

cell.Style.Custom=“m/dd/yyyy”;

Thank you for the help Laurence - everything is working great now.