donnytian / Npoi.Mapper

Use this tool to import or export data with Excel file. The tool is a convention based mapper between strong typed object and Excel data via NPOI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Format date with specific date "01/01/0001"

loschmitz opened this issue · comments

Hi!

It seems there is an error with the date formatting.
I need to export this specific date to excel ("01/01/0001") but it didn't work for this date while the other date is working.
In my excel generated for the date "01/01/0001", it set me "-1".

Below my code

public byte[] ExportToExcel(IEnumerable exportData, string sheetName = "Sheet1")
{
using var memoryStream = new MemoryStream();
var mapper = new Mapper();
mapper.UseFormat(typeof(DateTime?), "dd/MM/yyyy");
mapper.UseFormat(typeof(DateTime), "dd/MM/yyyy");
mapper.Save(memoryStream, exportData, sheetName);
return memoryStream.ToArray();
}

Thanks in advance!