c# 4.0 - In C#, Excel cell's custom date format not working with EPPlus -


i'm having trouble excel's custom format using epplus. here's code:

var destfile = new fileinfo(@"c:\temp\test1.xlsx"); var filename = "test1"; using (excelpackage pck = new excelpackage(destfile)) {     pck.workbook.worksheets.add(filename); // create worksheet in package        pck.workbook.worksheets[filename].cells["a2"].value = datetime.now.tostring("mm/dd/yyyy hh:mm:ss");     pck.workbook.worksheets[filename].cells["a2"].style.numberformat.format = "d-mmm-yy";      pck.save(); } 

i'm getting following: enter image description here

the custom format showed right, value in cell doesn't display format needed. here's i'm trying get: enter image description here

note: need full date value datetime.now.tostring("mm/dd/yyyy hh:mm:ss") other files, custom format need file.

what need change work?

thanks @paullabbott, here's correct answer:

pck.workbook.worksheets[filename].cells["a2"].value = datetime.now; 

this displays results needed.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -