How to make cell take on date type

Nov 7, 2014 at 7:59 PM
There is already a question about this, but I found it to be untrue (doing that does not make the value a date type).

If you open excel, type "1/1/2014" into a cell, arrow down, right click the cell, and check it's format under the "Number" tab, category "Date" will be selected. I want to do that programmatically. No matter what I try, the resulting cell comes up with "Custom" selected, not date.

I'm betting there is a way; just not documented anywhere...
Nov 10, 2014 at 1:48 PM
Edited Jul 28, 2015 at 12:43 PM
Setting Cell.Style.Numberformat.Format to "m/d/yyyy" does the equivalent of what I asked for. However, it seems that the underlying value is still numeric (double) and requires detecting the format (can check cell.Style.Numberformat.NumFmtID == 14) and converting (DateTime.FromOADate( (double)cell.Value )) to get the actual date upon reading the file.
Marked as answer by bradwood on 11/10/2014 at 6:48 AM