Skip to main content

ExcelSourceOptions Class

Contains options used to extract data from the Microsoft Excel workbook.

Namespace: DevExpress.DataAccess.Excel

Assembly: DevExpress.DataAccess.v24.1.dll

NuGet Packages: DevExpress.DataAccess, DevExpress.Win.PivotGrid, DevExpress.Win.TreeMap

Declaration

[TypeConverter(typeof(ExcelSourceOptions.ExcelSourceOptionsTypeConverter))]
public sealed class ExcelSourceOptions :
    ExcelSourceOptionsBase

Remarks

The ExcelDataSource class exposes the ExcelDataSource.SourceOptions property that accepts the ExcelSourceOptionsBase descendants (for instance, the ExcelSourceOptions objects). The ExcelSourceOptions class contains different options used to import data from the Microsoft Excel workbook.

The ExcelSourceOptions.ImportSettings property exposed by the ExcelSourceOptions class allows you to specify the approach used to import data from a workbook. For instance, you can select all data from the specified worksheet or specify the required cell range. To import data from the workbook, create the required ExcelSettingsBase object descendant and specify its settings.

The ExcelSourceOptions class also exposes the ExcelSourceOptions.Password property allowing you to specify the password used to access the protected workbook.

The following properties affect different options related to data extracting.

Example

The following code creates the ExcelDataSource and selects a cell range in the SalesPerson worksheet.

ExcelDataSource excelDataSource = new ExcelDataSource();
excelDataSource.Name = "Excel Data Source";
excelDataSource.FileName = HostingEnvironment.MapPath(@"~/App_Data/ExcelDataSource.xlsx");
ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings("SalesPerson", "A1:L2000");
excelDataSource.SourceOptions = new ExcelSourceOptions(worksheetSettings);
excelDataSource.Fill();

Inheritance

See Also