I'm trying to remove the time portion of a DateTimeOffset field in an Excel export and I just cannot get it to work.
Here's the field I'm using to display:
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime ProjectStartDate { get; set; }
Here's the field I'm mapping from:
public DateTimeOffset ProjectStartDate { get; set; }
and here's where I'm doing the mapping:
ProjectStartDate = p.ProjectStartDate,
I'm using EPPlus to generate the export as follows:
ExcelWorksheet wsExpenses = pck.Workbook.Worksheets.Add("Expenses");
wsExpenses.Cells["A1"].LoadFromCollection(expenses, true);
wsExpenses.Column(5).Style.Numberformat.Format = DateTimeFormatInfo.CurrentInfo.ShortDatePattern;