Skip to main content
All docs
V24.1

ExcelWorksheetSettings.WorksheetIndex Property

Allows you to bind an application or component to a sheet of an Excel file by index.

Namespace: DevExpress.DataAccess.Excel

Assembly: DevExpress.DataAccess.v24.1.dll

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

Declaration

public int? WorksheetIndex { get; set; }

Property Value

Type Description
Nullable<Int32>

The zero-based index of an Excel sheet to which an application or component is bound.

Remarks

The WorksheetIndex property uses zero-based indexing. The property has no effect if the WorksheetName property is specified.

Example

The example below demonstrates how to specify the WorksheetIndex property to bind an application or component to a sheet of an Excel file by index.

using DevExpress.DataAccess.Excel;
// ...
var excelDataSource = new ExcelDataSource() {
    FileName = "Path\\To\\Excel\\File.xlsx"
};

var excelWorksheetSettings = new ExcelWorksheetSettings() {
    WorksheetIndex = 0
};

var excelSourceOptions = new ExcelSourceOptions() {
    ImportSettings = excelWorksheetSettings,
    //...
};

excelDataSource.SourceOptions = excelSourceOptions;
excelDataSource.Fill();
//...
See Also