Skip to main content
A newer version of this page is available. .

ExcelWorksheetSettings Class

Contains options used to select data from the specified worksheet.

Namespace: DevExpress.DataAccess.Excel

Assembly: DevExpress.DataAccess.v19.2.dll

Declaration

public sealed class ExcelWorksheetSettings :
    ExcelSettingsBase

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();
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

Object
ExcelSettingsBase
ExcelWorksheetSettings
See Also