WeihanLi/WeihanLi.Npoi

Attributes.Sheet(StartRowIndex = 0) dont work

joylin1984 opened this issue · 4 comments

net 4.5.2 WeihanLi.Npoi 1.3.7

Codes for test:

    [WeihanLi.Npoi.Attributes.Sheet(StartRowIndex = 0)]
    internal class MyClass
    {
        [WeihanLi.Npoi.Attributes.Column(Index = 0)]
        public int id { get; set; }

        [WeihanLi.Npoi.Attributes.Column(Index = 1)]
        public string Name { get; set; }

        [WeihanLi.Npoi.Attributes.Column(Index = 2)]
        public double pp { get; set; }

        [WeihanLi.Npoi.Attributes.Column(Index = 3)]
        public DateTime year { get; set; } = DateTime.Now;
    }
            var res = ExcelHelper.ToEntityList<MyClass>("test1.xlsx", 0);
            foreach (var r in res)
            {
                Console.WriteLine($"{r.id}---{r.Name}---{r.pp}---{r.year}");
            }

Exception:
System.InvalidOperationException: Cannot get a text value from a numeric cell

test1.xlsx

额,看了源码,HeaderRowIndex 最少为0,也就是必须要有行头~~~
是否可以增加无行头的设置呢?

It should be fixed with #27 , please try 1.3.8

你可以用一下 1.3.8 版本的包试一下,我本地测试的是可以了,如果还有问题欢迎反馈

image

nice, 1.3.8 version is work

OK, thanks for the info