Skip to content

Releases: chsword/Excel2Object

2.0.0.122

26 Dec 06:49

Choose a tag to compare

- [x] support standard excel model

  - [x] excel & JSON convert
  - [x] excel & Dictionary<string,object> convert

2.0.0.113

26 Dec 04:03

Choose a tag to compare

support target framework net452 and netstandard2.0

for issue #13

2.0.0.105

25 Dec 13:44

Choose a tag to compare

add restore nuget to build

1.0.0.91

24 Aug 03:39

Choose a tag to compare

#11

1.0.0.80

19 Jul 06:47

Choose a tag to compare

支持 Uri 的转换

1.0.0.43

16 Apr 06:22

Choose a tag to compare

整理特殊类型转换

1.0.0.32

31 Dec 02:00

Choose a tag to compare

Update Chsword.Excel2Object.nuspec

1.0.0.26

31 Dec 00:34

Choose a tag to compare

Update README.md

v1.0.0.14

12 Jan 08:01

Choose a tag to compare

Excel convert to .NET Object

NuGet Install

PM> Install-Package Chsword.Excel2Object

Demo Code

Model

    public class ReportModel
    {
        [Excel("标题",Order=1)]
        public string Title { get; set; }
        [Excel("用户",Order=2)]
        public string Name { get; set; }
    }

Model List

      var models = new List<ReportModel>
            {
                new ReportModel{Name="a",Title="b"},
                new ReportModel{Name="c",Title="d"},
                new ReportModel{Name="f",Title="e"}
            };

Convert Object to Excel file.

      var exporter = new ExcelExporter();
      var bytes = exporter.ObjectToExcelBytes(models);
      File.WriteAllBytes("C:\\demo.xls", bytes);

Convert Excel file to Object

      var importer = new ExcelImporter();
      IEnumerable<ReportModel> result = importer.ExcelToObject<ReportModel>("c:\\demo.xls");

With ASP.NET MVC
In ASP.NET MVC Model, DisplayAttribute can be supported like ExcelAttribute.

Document

http://www.cnblogs.com/chsword/p/excel2object.html

Reference

NPOI
https://github.com/tonyqus/npoi