Skip to main content
Row

TableCollection.Add(Object, CellRange) Method

Creates a table from the specified range, adds it to the collection and binds it to the data source.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v24.1.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

Table Add(
    object dataSource,
    CellRange range
)

Parameters

Name Type Description
dataSource Object

A data source object whose data should be retrieved in the worksheet.

range CellRange

A CellRange used to create a table.

Returns

Type Description
Table

A Table object that is the newly created table.

Remarks

The following rules are used, depending on the dimensions of the specified range:

Range Result
A single cell. A table is created to include all the data of the data source. It has the number of columns equal to the number of data fields, and the number of rows equal to the number of data rows in the data source. The top left corner of the table is the specified cell.
A range with a number of columns less than the number of data fields in the data source. An WorksheetDataBindingCollection.Error event occurs that indicates a column number mismatch. The table is not created.
A range with the number of columns equal to the number of data fields in the data source. A table is created with the number of rows equal to the number of data rows in the data source.
A range with a number of columns greater than the number of data fields in the data source A table is created that includes all columns from the data source and a number of empty columns to fill the entire range. The table has a number of rows equal to the number of data rows in the data source.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Add(Object, CellRange) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also