How to apply Date Format for Excel Cell

Oct 3, 2011 at 12:54 PM


I am using EPPlus for excel export purpose. I want to apply date format for cell . How should i do it. I have tried this way

ws.Cells[rowNum, colNum].Style.Numberformat.Format = "DD/MM/YYYY"; But its not working. Still the cell have number format.

Oct 4, 2011 at 8:35 PM

That should work. Make sure that the value of the cell isn't a string (have a look at the FAQ and the samples).

Oct 5, 2011 at 10:01 AM


when i implement this statement ws.Cells[rowNum, colNum].Style.Numberformat.Format = "DD/MM/YYYY".

Cell value gets display as "10/05/2011". But once you double click on that cell its value get converted in number as 40821.00.

As cell format is Number and not Date Format.

Could u please suggest what to do?

Oct 9, 2011 at 5:31 PM

The standard date format is mm-dd-yy, it will show different formats depending on your regional settings.

If its not what you want read the FAQ how to check the numberformat of an existing xlsx file.

Oct 10, 2011 at 9:07 AM
Edited Oct 10, 2011 at 9:08 AM

Got solution for my Problem as below, it set custom format for that field... but its consider as Date..... :)

We need to set Formula field instead of Value field.

ws.Cells[rowNum, colNum].Formula = "=DATE(2011,10,4)";

ws.Cells[rowNum, colNum].Style.Numberformat.Format = "DD/MM/YYYY";

Nov 10, 2014 at 1:53 PM
This does not store the value as a date, but rather a number. See