CsvHelper的IndexAttribute 可以设置C#中的类和实际的csv文件列头名称不同;
The
IndexAttribute
allows you to specify which position the CSV field is that you want to use for the property.You can also map by name. Let's use our lower case header example from before and see how we can use attributes instead of changing the header matching.
public class Model
{
[Name("1")]
public string One { get; set; }
[Name("2")]
public string Two { get; set; }
[Name("3")]
public string Three { get; set; }
[Name("4")]
public string Four { get; set; }
}