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

Mapper.Take<T>() works wrong sometimes when cell is numeric as text maps to string property

xjfnet opened this issue · comments

sorry for my broken english
column header name is: NF
cell format is text
cell value is 2017

public class Entity
{
...
public string NF { get; set; }
...
}
var set = mapper.Take<Entity>();
var isnull = set.All(x => x.NF == null);

isnull is true
but this works well

Mapper.Take<dynamic>()

First make sure there is a column named "NF" in the first Excel row. then

  1. Try set[0].Value.NF property
  2. Otherwise try define NF as int type. In Excel, that column might be formatted as numbers automatically. Or you can manually set as text format in Excel.

sorry, this is my mistake
i have two xlsx, and they has some column with the same name
i read the wrong xlsx file....
please remove this issue