Click or drag to resize
CreateDataTableOptions Class
Represents options creating DataTable and filling it with values from ExcelWorksheet.
Inheritance Hierarchy
SystemObject
  GemBox.SpreadsheetCreateDataTableOptions

Namespace: GemBox.Spreadsheet
Assembly: GemBox.Spreadsheet (in GemBox.Spreadsheet.dll) Version: 39.3.30.1189
Syntax
public sealed class CreateDataTableOptions

The CreateDataTableOptions type exposes the following members.

Constructors
  NameDescription
Public methodCreateDataTableOptions
Initializes an instance of CreateDataTableOptions class.
Public methodCreateDataTableOptions(String, Int32, Int32)
Initializes an instance of CreateDataTableOptions class.
Public methodCreateDataTableOptions(Int32, Int32, Int32, Int32)
Initializes an instance of CreateDataTableOptions class.
Top
Properties
  NameDescription
Public propertyColumnHeaders
Gets or sets a value indicating whether to use first row of extracted data for column headers.
Public propertyColumnIndexes
Gets a list of indexes of columns which will be extracted.
Public propertyExtractDataOptions
Gets or sets ExtractDataOptions.
Public propertyNumberOfColumns
Gets or sets the number of columns being extracted from ExcelWorksheet.
Public propertyNumberOfRows
Gets or sets the number of rows being extracted from ExcelWorksheet.
Public propertyResolution
Gets or sets the resolution type that specifies how column types will be resolved in created DataTable, see ColumnTypeResolution.
Public propertyStartColumn
Gets or sets the index of the first column of data being extracted from ExcelWorksheet.
Public propertyStartRow
Gets or sets the index of the first row of data being extracted from ExcelWorksheet.
Top
Remarks
Use default constructor to extract used cell range.
Examples

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.ColumnIndexes.Add(0);
extractOnlyFirstAndLastColumn.ColumnIndexes.Add(2);
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