ExcelWorksheetSettings Class
Contains options used to select data from the specified worksheet.
Namespace: DevExpress.DataAccess.Excel
Assembly: DevExpress.DataAccess.v18.1.dll
Declaration
Remarks
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 select all data from the specified worksheet, create the ExcelWorksheetSettings object and specify the worksheet name using the ExcelWorksheetSettings.WorksheetName property. To select a range of cells from the specified worksheet, you also need to specify the ExcelWorksheetSettings.CellRange property.
The following example shows how to select the A1:F20 range of cells located on the Sheet1 worksheet.
ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings();
worksheetSettings.WorksheetName = "Sheet1";
worksheetSettings.CellRange = "A1:F20";
As an alternative, you can specify the sheet and the cell range using only the ExcelWorksheetSettings.CellRange property.
ExcelWorksheetSettings worksheetSettings = new ExcelWorksheetSettings();
worksheetSettings.CellRange = "Sheet1!A1:F20";
Example
This example shows how to create an ExcelDataSource and select the specific cell range from the SalesPerson worksheet.
ExcelDataSource excelDataSource = new ExcelDataSource("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();
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ExcelWorksheetSettings class.
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.