Class ExcelColumn
This attribute defines either which column index is mapped to the property or the header name that identifies the column By default, when reading from an excel file, a header column is expected in the first row. The name of the header is used to match with the property names of the object. With this attribute, you can define the column index of the excel column for the property or a different header name for a property. The index starts at 0.
Inheritance
Inherited Members
Namespace: ETLBox.Excel
Assembly: ETLBox.Excel.dll
Syntax
[AttributeUsage(AttributeTargets.Property)]
public class ExcelColumn : Attribute
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }
Constructors
ExcelColumn()
Declaration
public ExcelColumn()
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }
ExcelColumn(int, string)
Declaration
public ExcelColumn(int columnIndex, string columnName)
Parameters
Type | Name | Description |
---|---|---|
int | columnIndex | |
string | columnName |
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }
ExcelColumn(int)
Declaration
public ExcelColumn(int columnIndex)
Parameters
Type | Name | Description |
---|---|---|
int | columnIndex |
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }
ExcelColumn(string)
Declaration
public ExcelColumn(string columnName)
Parameters
Type | Name | Description |
---|---|---|
string | columnName |
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }
Properties
ColumnIndex
Declaration
public int ColumnIndex { get; set; }
Property Value
Type | Description |
---|---|
int |
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }
ColumnName
Declaration
public string ColumnName { get; set; }
Property Value
Type | Description |
---|---|
string |
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }
PropertyName
Declaration
public string PropertyName { get; set; }
Property Value
Type | Description |
---|---|
string |
Examples
public class MyPoco { [ExcelColumn("HeaderName")] public string ColumnByHeaderName { get; set; } [ExcelColumn(2)] public string ThirdColumnInExcel { get; set; } }