This project has moved and is read-only. For the latest updates, please go here.

How to set the Date Category (Number Format)

Dec 6, 2012 at 8:09 PM
Edited Dec 6, 2012 at 8:09 PM


I am using a SqlDataReader to populate my sheet data and when I use the following number format for dates, it formats correctly but when I look at the "Format Cells" from excel, the category is "Custom" not "Date".

I looked at some of the code examples in the download and it looks like the category is being set to "Date" but I'm not sure what I am missing. Any help would be great.

// set the format
xlsSheet.Cells[rowIndex, i].Style.Numberformat.Format = "mm/dd/yyyy";

// ...

// read and write the value from the data row
xlsSheet.SetValue(rowIndex, i, dr[i - 1]);