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

Parsing DateTime fails w/ NPOI 2.5.1

davesheldon opened this issue · comments

Given class:

private class Sample {
            [Display(Name = "Employee #")]
            public string EmployeeID { get; set; }

            [Display(Name = "Date Worked")]
            public DateTime DateWorked { get; set; }
        }
    }

We are seeing failures mapping DateTimes when updating to NPOI 2.5.1.

The excel file we're receiving uses a custom date format of m/d/yyyy h:mm. It parses correctly when we downgrade to our previous version (NPOI 2.4.1).

hi, seems NPOI 2.5.1 brings some trouble for us.

Either specify format for a mapping:

mapper.Format<SampleClass>("m/d/yyyy h:mm", o => o.DateProperty);

Or specify for a type:

mapper.UseFormat(typeof(DateTime), "m/d/yyyy h:mm");

This looks to be a bug of NPOI 2.5.1. @davesheldon can you open a issue in NPOI issues

closing this, please try with the latest version