corelibraries-devexpress-dot-dataaccess-dot-excel-2a93023e.md
Contains options used to select data from the specified worksheet.
Namespace : DevExpress.DataAccess.Excel
Assembly : DevExpress.DataAccess.v25.2.dll
NuGet Package : DevExpress.DataAccess
public sealed class ExcelWorksheetSettings :
ExcelSettingsBase
Public NotInheritable Class ExcelWorksheetSettings
Inherits ExcelSettingsBase
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";
Dim worksheetSettings As 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";
Dim worksheetSettings As New ExcelWorksheetSettings()
worksheetSettings.CellRange = "Sheet1!A1:F20"
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();
Dim excelDataSource As New ExcelDataSource()
excelDataSource.Name = "Excel Data Source"
excelDataSource.FileName = HostingEnvironment.MapPath("~/App_Data/ExcelDataSource.xlsx")
Dim worksheetSettings As New ExcelWorksheetSettings("SalesPerson", "A1:L2000")
excelDataSource.SourceOptions = New ExcelSourceOptions(worksheetSettings)
excelDataSource.Fill()
Object ExcelSettingsBase ExcelWorksheetSettings
See Also