Table of Contents

Class ToDataTableOptions

Namespace
OfficeOpenXml.Export.ToDataTable
Assembly
EPPlus.dll

This class contains options for the ToDataTable method of ExcelRangeBase.

public class ToDataTableOptions
Inheritance
ToDataTableOptions
Inherited Members

Properties

AlwaysAllowNull

If true, the AllowNull will be overridden and null values will be allowed in all columns.

public bool AlwaysAllowNull { get; set; }

Property Value

bool

ColumnNameParsingStrategy

NameParsingStrategy to use when parsing the first row of the range to column names

public NameParsingStrategy ColumnNameParsingStrategy { get; set; }

Property Value

NameParsingStrategy

ColumnNamePrefix

If no column names are specified, this prefix will be used followed by a number

public string ColumnNamePrefix { get; set; }

Property Value

string

DataIsTransposed

Set to true if the worksheet is contains transposed data.

public bool DataIsTransposed { get; set; }

Property Value

bool

DataTableName

Name of the data table

public string DataTableName { get; set; }

Property Value

string

DataTableNamespace

Namespace of the data table

public string DataTableNamespace { get; set; }

Property Value

string

EmptyRowStrategy

Sets how empty rows in the range are handled when detected

public EmptyRowsStrategy EmptyRowStrategy { get; set; }

Property Value

EmptyRowsStrategy

ExcelErrorParsingStrategy

Sets how Excel error values are handled when detected.

public ExcelErrorParsingStrategy ExcelErrorParsingStrategy { get; set; }

Property Value

ExcelErrorParsingStrategy

FirstRowIsColumnNames

If true, the first row of the range will be used to collect the column names of the DataTable. The column names will be set according to the ColumnNameParsingStrategy used.

public bool FirstRowIsColumnNames { get; set; }

Property Value

bool

Mappings

Mappings that specifies columns from the range and how these should be mapped to the DataTable

public DataColumnMappingCollection Mappings { get; }

Property Value

DataColumnMappingCollection
See Also

PredefinedMappingsOnly

If true, only columns that are specified in the Mappings collection are included in the DataTable.

public bool PredefinedMappingsOnly { get; set; }

Property Value

bool

SkipNumberOfRowsEnd

Number of rows that will be skipped from the end (bottom) of the range.

public int SkipNumberOfRowsEnd { get; set; }

Property Value

int

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.

public int SkipNumberOfRowsStart { get; set; }

Property Value

int

Methods

Create()

Creates an instance of ToDataTableOptions with default values set.

public static ToDataTableOptions Create()

Returns

ToDataTableOptions
See Also
OfficeOpenXml.Export.ToDataTable.ToDataTableOptions.Default

Create(Action<ToDataTableOptions>)

Creates an instance of ToDataTableOptions. Use the configHandler parameter to set the values on it.

public static ToDataTableOptions Create(Action<ToDataTableOptions> configHandler)

Parameters

configHandler Action<ToDataTableOptions>

Use this to configure the ToDataTableOptions instance in a lambda expression body.

Returns

ToDataTableOptions

The configured ToDataTableOptions

SetPrimaryKey(params int[])

Sets the primary key of the data table.

public void SetPrimaryKey(params int[] zeroBasedRangeIndexes)

Parameters

zeroBasedRangeIndexes int[]

The index or indexes of one or more column in the range that builds up the primary key of the DataTable

SetPrimaryKey(params string[])

Sets the primary key of the data table.

public void SetPrimaryKey(params string[] columnNames)

Parameters

columnNames string[]

The name or names of one or more column in the DataTable that constitutes the primary key