Click or drag to resize
ExcelWorksheetCreateDataTable Method
Creates a DataTable and fills it with data from this ExcelWorksheet in a manner specified by create options, see CreateDataTableOptions.

Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version:
public DataTable CreateDataTable(
	CreateDataTableOptions options


Type: GemBox.SpreadsheetCreateDataTableOptions
Options that describe how DataTable will be created and filled with data extracted from ExcelWorksheet.

Return Value

Type: DataTable
DataTable with data from specified cells.

Following code demonstrates how to extract data from ExcelWorksheet to DataTable using CreateDataTable(CreateDataTableOptions) method.

// Creates DataTable and extracts used cell range to it.
DataTable usedCellRangeData = ws.CreateDataTable(new CreateDataTableOptions());

// Creates DataTable and extracts specific range of cells from the worksheet.
DataTable specificRangeData = ws.CreateDataTable(new CreateDataTableOptions(1, 1, 5, 2));

// Creates DataTable and extracts only first and third column.
CreateDataTableOptions extractOnlyFirstAndLastColumn = new CreateDataTableOptions();
extractOnlyFirstAndLastColumn.NumberOfRows = ws.Rows.Count;
DataTable specificColumnsData = ws.CreateDataTable(extractOnlyFirstAndLastColumn);

// Creates DataTable and extracts used cell range using specified column type resolution.
DataTable dataTableWithStrings = ws.CreateDataTable(new CreateDataTableOptions()
    Resolution = ColumnTypeResolution.StringCurrentCulture
See Also