ExternalDataSourceOptions Class
Contains options for data retrieval from an external data source when establishing a data binding.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
Remarks
An ExternalDataSourceOptions class instance is assigned as a parameter to the WorksheetDataBindingCollection.BindToDataSource method.
Example
private void BindWeatherReportToRange(object weatherDatasource, CellRange bindingRange) {
Worksheet sheet = spreadsheetControl1.Document.Worksheets[0];
// Check for range conflicts.
var dataBindingConflicts = sheet.DataBindings.
Where(d => (d.Range.RightColumnIndex >= bindingRange.LeftColumnIndex) || (d.Range.BottomRowIndex >= bindingRange.TopRowIndex)) ;
if (dataBindingConflicts.Count() > 0) {
MessageBox.Show("Cannot bind the range to data.\r\nThe worksheet contains other binding ranges which may conflict.", "Range Conflict");
return;
}
// Specify the binding options.
ExternalDataSourceOptions dsOptions = new ExternalDataSourceOptions();
dsOptions.ImportHeaders = true;
dsOptions.CellValueConverter = new MyWeatherConverter();
dsOptions.SkipHiddenRows = true;
// Bind the data source to the worksheet range.
WorksheetDataBinding sheetDataBinding = sheet.DataBindings.BindToDataSource(weatherDatasource, bindingRange, dsOptions);
// Adjust the column width.
sheetDataBinding.Range.AutoFitColumns();
}
Inheritance
Object
DataSourceOptionsBase
ExternalDataSourceOptions
See Also