Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date Formatting in ClosedXML

Tags:

closedxml

I have date's in an excel sheet that I am reading from. What I like to do is to force the date to be in mm/dd/yyyy Is there a way to do this in Closed XML.

I took at a look https://closedxml.codeplex.com/documentation but could not find how to force or update the date to a certain format.

like image 304
Nate Pet Avatar asked Jul 29 '15 19:07

Nate Pet


1 Answers

If you want to do it on Specific cell then you have to use

worksheet.Cell(row,column).Style.NumberFormat.Format = "mm/dd/yyyy";

and

If you want to do it on multiple cells then you have to use

worksheet.Range(row,column,row,column).Style.NumberFormat.Format = "mm/dd/yyyy";
like image 179
Smit Patel Avatar answered Oct 12 '22 13:10

Smit Patel