Skip to main content
Row

WorksheetExtensions.CreateDataTable(Worksheet, CellRange, Boolean, Boolean) Method

Creates an empty data table from the specified cell range.

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this method in production code.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v23.2.dll

NuGet Package: DevExpress.Document.Processor

Declaration

public static DataTable CreateDataTable(
    this Worksheet sheet,
    CellRange range,
    bool rangeHasHeaders,
    bool stringColumnType
)

Parameters

Name Type Description
sheet Worksheet

A Worksheet object that is a worksheet containing the specified range.

range CellRange

A CellRange of cells that will be transformed to a data table.

rangeHasHeaders Boolean

true, to use the content of the first row in a range as column names in a data table; otherwise, false.

stringColumnType Boolean

true, to use string data type for all columns in the resulting data table; otherwise, false.

Returns

Type Description
DataTable

A DataTable object that is the resulting data table.

Remarks

The CreateDataTable method creates an empty data table. The number of columns in a data table is the same as the number of columns in the specified range. The first row of the specified cell range defines column names if the rangeHasHeaders parameter is set to true. If the stringColumnType parameter is true, all columns in a resulting data table will be of the string type.

The first row in the specified range is used to determine column data types if the rangeHasHeaders and the stringColumnType parameters are set to false.

If the first row in a specified range contains column names (the rangeHasHeaders parameter for the CreateDataTable method is set to true), the second row is used to determine the column data types.

To determine the column data type for the resulting data table, the CellValue.Type of data contained in a cell is used.

See Also