officefileapi-devexpress-dot-spreadsheet-4a73edb0.md
Contains information about a Table bound to an external data source or used to create a data source.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
public interface WorksheetTableDataBinding :
WorksheetDataBinding
Public Interface WorksheetTableDataBinding
Inherits WorksheetDataBinding
The following members return WorksheetTableDataBinding objects:
The WorksheetTableDataBinding objects, as well as the WorksheetDataBinding objects, are contained in the WorksheetDataBindingCollection, accessible using the Worksheet.DataBindings property. Cast the item in the collection to the WorksheetTableDataBinding type to obtain the WorksheetTableDataBinding object.
The WorksheetTableDataBinding object is created, added to the Worksheet.DataBindings collection and returned by the WorksheetDataBindingCollection.BindTableToDataSource method. The Table.GetDataSource method also creates a WorksheetTableDataBinding object and adds it to the worksheet’s collection.
When the WorksheetTableDataBinding object is deleted, the associated table remains with its data. When the associated table is deleted, the WorksheetTableDataBinding object is also deleted.
private void BindWeatherReportToTable(object weatherDatasource, CellRange bindingRange) {
Worksheet sheet = spreadsheetControl1.Document.Worksheets[0];
// Remove all data bindings bound to the specified data source.
sheet.DataBindings.Remove(weatherDatasource);
// Specify the binding options.
ExternalDataSourceOptions dsOptions = new ExternalDataSourceOptions();
dsOptions.ImportHeaders = true;
dsOptions.CellValueConverter = new MyWeatherConverter();
dsOptions.SkipHiddenRows = true;
// Create a table and bind the data source to the table.
try {
WorksheetTableDataBinding sheetDataBinding = sheet.DataBindings.BindTableToDataSource(weatherDatasource, bindingRange, dsOptions);
sheetDataBinding.Table.Style = spreadsheetControl1.Document.TableStyles[BuiltInTableStyleId.TableStyleMedium14];
// Adjust the column width.
sheetDataBinding.Range.AutoFitColumns();
}
catch(Exception e) {
MessageBox.Show(e.Message, "Binding Exception");
}
}
Private Sub BindWeatherReportToTable(ByVal weatherDatasource As Object, ByVal bindingRange As CellRange)
Dim sheet As Worksheet = spreadsheetControl1.Document.Worksheets(0)
' Remove all data bindings bound to the specified data source.
sheet.DataBindings.Remove(weatherDatasource)
' Specify the binding options.
Dim dsOptions As New ExternalDataSourceOptions()
dsOptions.ImportHeaders = True
dsOptions.CellValueConverter = New MyWeatherConverter()
dsOptions.SkipHiddenRows = True
' Create a table and bind the data source to the table.
Try
Dim sheetDataBinding As WorksheetTableDataBinding = sheet.DataBindings.BindTableToDataSource(weatherDatasource, bindingRange, dsOptions)
sheetDataBinding.Table.Style = spreadsheetControl1.Document.TableStyles(BuiltInTableStyleId.TableStyleMedium14)
' Adjust the column width.
sheetDataBinding.Range.AutoFitColumns()
Catch e As Exception
MessageBox.Show(e.Message, "Binding Exception")
End Try
End Sub
See Also
WorksheetTableDataBinding Members