. net open source import and export library released by magicodes.ie 2.5

Time:2021-11-22

Today, we released version 2.5, which is of course inseparable from your understanding ofMagicodes.IEToday, as usual, I listed some important updates of this version.

Of course, in this version, we have designed a new logo

file

Excel export

  • Excel export supports headerrowindex#164

stayExcelExporterAttributeAdd in export property classHeaderRowIndexProperty, which is convenient to specify that the export starts from the first line.

When exporting an enumeration type, we can export the string name of the enumeration itself through valuemapping at first. Now we can use
DescriptionAttribute
DisplayAttribute,
DisplayNameAttribute
Implement text value export

enum Sex
{
        /// 
        ///Male
        /// 
        [description ("male")]
        boy = 1,
        /// 
        ///Female
        /// 
        [description ("female")]
        girl = 2
}
  • Modify TABLESTYLE to enumeration type

Before that, we willTableStyleProperties are placed inExporterAttributeIn the basic feature, our TABLESTYLE attribute is a string at first,
However, it brings us unnecessary trouble. It is difficult for users to find these style names, so here we replace them with enumeration types to facilitate users from the list
Find related styles

[excelexporter (name = "test", TABLESTYLE = tablestyles. Light10)]

Excel import

  • Excel generates and imports templates and supports built-in data validation#167

Support for built-in data validation can beIsInterValidationProperty is turned on, and it should be noted that only
supportMaxLengthAttribute
MinLengthAttribute
StringLengthAttribute
RangeAttribute

It supports the opening of built-in data verification.
file

file

The display operation of input prompt is supported.

file

The example code is as follows:

public class GenerateStudentImportSheetDataValidationDto
    {
        /// 
        ///Serial number
        /// 
        [importerheader (name = "sequence number", isintervalidation = true)]
        [range (minimum: 0, maximum: 20, ErrorMessage = "the maximum sequence number is 20")]
        public long SerialNumber { get; set; }

        /// 
        ///Student status number
        /// 
        [importerheader (name = "student status number", isallowrepeat = false, isintervalidation = true)]
        [MaxLength (30, ErrorMessage = "the number of student ID exceeds the maximum limit, please modify!")]
        public string StudentCode { get; set; }

        /// 
        ///Name
        /// 
        [importerheader (name = "name")]
        [required (ErrorMessage = "student name cannot be empty")]
        [MaxLength (50, ErrorMessage = "the number of name words exceeds the maximum limit, please modify!")]
        public string Name { get; set; }

        /// 
        ///Age
        /// 
        [importerheader (name = "age", isintervalidation = true)]
        [range (minimum: 18, maximum: 20, ErrorMessage = "the age range needs to be 18-20")]
        public int Age { get; set; }

        /// 
        ///     MinTest
        /// 
        [ImporterHeader(Name = "MinTest", IsInterValidation = true)]
        [minlength (5, ErrorMessage = "minimum length is 5")]
        public string MinTest { get; set; }

        /// 
        ///Ignore type
        /// 
        [importerheader (name = "ignore type", isintervalidation = true)]
        [range (minimum: 18, maximum: 20, ErrorMessage = "the age range should be 18-20 years old", errormessageresourcetype = typeof (string))]
        public int IgnoreType { get; set; }

        [importerheader (name = "date of birth", isintervalidation = true, showinputmessage = "date of entry")]
        [range (typeof (datetime), minimum: "2020-10-20", maximum: "2020-10-24", ErrorMessage = "date range is out of range")]
        public DateTime Birthday { get; set; }
}

Note: data range validation only supports datetime and int types

  • Import support for columnindex#198

Import function supportColumnIndexYou can specify a data column by, so that we can also directly specify a complex column name structure
Easy response

file

[importerheader (name = "age", columnindex = 3)]
public int? Age { get; set; }

Welcome to join wechat group by scanning code

. net open source import and export library released by magicodes.ie 2.5

https://github.com/dotnetcore/Magicodes.IE