This kind of library is still in the idea, then will find time to implement it ~
Brief introduction:
This excel resolves a simple two-dimensional Excel into a C # list entity, preventing developers from repeating the wheel. Developers can define data specifications for Excel tables through a series of feature tags, and make simple check-up, such as length, size, non-nullable, and so on.
The Excel format supported by the idea is as follows:
Name |
Age |
Tel |
Address |
ISAdmin |
Jax |
18 |
15399126333 |
Xi'an |
True |
Bob |
52 |
15821487157 |
Yulin |
False |
Eventually through this class library, you can parse to a list<person>, and each value in Excel is correctly populated with the object:
Public classperson{ Public stringName {Get;Set; } Public intAge {Get;Set; } Public stringTel {Get;Set; } Public stringAddress {Get;Set; } Public BOOLISAdmin {Get;Set; }}
Realize:
1. Specify the name of the table header for the property, or the ordinal number of the column, by the attribute label on the object property, and finally locate the value of the cell to which the property is populated.
2. Define validation rules, similar to Required,maxlength, MinLength, MaxValue, availablevalues, by attribute labels on attributes, These feature tags are best used under the Sytem class library (what we usually write on ViewModel), and if not, define for yourself.
3. The types of int, string, Decimal, DateTime, Double, Bool, enum are supported first, and the nullable types of these types are supported (Int?,decimal?).
4. Support to verify that the Excel template used by the user is correct based on the table header text
Refer to: Https://github.com/chsword/Excel2Object/tree/master/Chsword.Excel2Object
This has achieved the basic function, but we have to expand on his basis some common methods, such as the validation of data legitimacy, template correctness and so on.
Introduction to two-dimensional Excel Automation parsing class library