Class ToDataTableOptions
This class contains options for the ToDataTable method of ExcelRangeBase.
Inheritance
Inherited Members
Namespace: OfficeOpenXml.Export.ToDataTable
Assembly: EPPlus.dll
Syntax
public class ToDataTableOptions
Properties
ColumnNameParsingStrategy
NameParsingStrategy to use when parsing the first row of the range to column names
Declaration
public NameParsingStrategy ColumnNameParsingStrategy { get; set; }
Property Value
Type | Description |
---|---|
NameParsingStrategy |
ColumnNamePrefix
If no column names are specified, this prefix will be used followed by a number
Declaration
public string ColumnNamePrefix { get; set; }
Property Value
Type | Description |
---|---|
System.String |
DataTableName
Name of the data table
Declaration
public string DataTableName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
DataTableNamespace
Namespace of the data table
Declaration
public string DataTableNamespace { get; set; }
Property Value
Type | Description |
---|---|
System.String |
EmptyRowStrategy
Sets how empty rows in the range are handled when detected
Declaration
public EmptyRowsStrategy EmptyRowStrategy { get; set; }
Property Value
Type | Description |
---|---|
EmptyRowsStrategy |
ExcelErrorParsingStrategy
Sets how Excel error values are handled when detected.
Declaration
public ExcelErrorParsingStrategy ExcelErrorParsingStrategy { get; set; }
Property Value
Type | Description |
---|---|
ExcelErrorParsingStrategy |
FirstRowIsColumnNames
If true, the first row of the range will be used to collect the column names of the System.Data.DataTable. The column names will be set according to the ColumnNameParsingStrategy used.
Declaration
public bool FirstRowIsColumnNames { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Mappings
Mappings that specifies columns from the range and how these should be mapped to the System.Data.DataTable
Declaration
public DataColumnMappingCollection Mappings { get; }
Property Value
Type | Description |
---|---|
DataColumnMappingCollection |
See Also
PredefinedMappingsOnly
If true, only columns that are specified in the Mappings collection are included in the DataTable.
Declaration
public bool PredefinedMappingsOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
SkipNumberOfRowsEnd
Number of rows that will be skipped from the end (bottom) of the range.
Declaration
public int SkipNumberOfRowsEnd { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
SkipNumberOfRowsStart
Number of rows that will be skipped from the start (top) of the range. If FirstRowIsColumnNames is true, this will be applied after the first row (column names) has been read.
Declaration
public int SkipNumberOfRowsStart { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Create()
Creates an instance of ToDataTableOptions with default values set.
Declaration
public static ToDataTableOptions Create()
Returns
Type | Description |
---|---|
ToDataTableOptions |
See Also
Create(Action<ToDataTableOptions>)
Creates an instance of ToDataTableOptions. Use the configHandler
parameter to set the values on it.
Declaration
public static ToDataTableOptions Create(Action<ToDataTableOptions> configHandler)
Parameters
Type | Name | Description |
---|---|---|
System.Action<ToDataTableOptions> | configHandler | Use this to configure the ToDataTableOptions instance in a lambda expression body. |
Returns
Type | Description |
---|---|
ToDataTableOptions | The configured ToDataTableOptions |
SetPrimaryKey(Int32[])
Sets the primary key of the data table.
Declaration
public void SetPrimaryKey(params int[] zeroBasedRangeIndexes)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | zeroBasedRangeIndexes | The index or indexes of one or more column in the range that builds up the primary key of the System.Data.DataTable |
SetPrimaryKey(String[])
Sets the primary key of the data table.
Declaration
public void SetPrimaryKey(params string[] columnNames)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | columnNames | The name or names of one or more column in the System.Data.DataTable that constitutes the primary key |