I'm trying to export excel using ClosedXML and I have problem in fixing datetime format.
My desired cell format is "dd.MM.yyyy HH:mm:ss"
but when the day of the month is 12 or less, it automatically switches the day and the month and results in "MM.dd.yyyy HH:mm:ss"
.
var date = Convert.ToDateTime(colValue);
value = date.ToString("dd.MM.yyyy HH:mm:ss");
worksheet.Cell(x,y).Style.NumberFormat.Format = "dd.MM.yyyy HH:mm:ss";
worksheet.Cell(x,y).Value = value;
When the day of the month is 13 or above, it results in correct format.