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.
MIT License
589 stars 114 forks source link

Apply .Trim() when reading the column names by default. #65

Closed xDidier901 closed 4 years ago

xDidier901 commented 4 years ago

Hi, I have encountered this issue where defining a class to map my Excel file, if the name of the column in the Excel file has an space at the end, the mapping will fail and will parse everything as null/default.

Example:

public class MyClass
    {
        [Column("Property")]
        public string MyProperty { get; set; }
    }

In this case, if the name of the column in the Excel file is "Property " (<--- check the extra space at the end) the mapping will fail and will give you everything as null.

It would be nice if by default, it would add a .Trim() at the end of the columnName so we can skip this kind of situations.

donnytian commented 4 years ago

fixed in v3.5