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

Would be nice to have a way to define a default value #91

Closed POFerro closed 2 years ago

POFerro commented 3 years ago

Hi,

When mapping from an Excel it would be nice to have a way to define a default value for properties when cell is blank. Proposal 1- Use DefaultValueAttribute from System.ComponentModel and use the value defined as default value, this should be guarded by a property in Mapper since it would be a breaking change if people alredy use this attribute in model for other purposes. Proposal 2- Add DefaultValue property in ColumnAttribute.

I believe this feature would help, it sure helps me on my project :). Thanks POFerro