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

WorksheetCollection Interface

A collection of worksheets contained in a workbook.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v18.2.Core.dll

Declaration

public interface WorksheetCollection :
    ISimpleCollection<Worksheet>,
    IEnumerable<Worksheet>,
    IEnumerable,
    ICollection

The following members return WorksheetCollection objects:

Remarks

The WorksheetCollection object stores worksheets of the workbook (a workbook always contains at least one worksheet). Use the IWorkbook.Worksheets property to access this object. The WorksheetCollection.Item property enables you to get an individual worksheet by its name or index in the collection.

To add a new worksheet to the workbook, use the WorksheetCollection.Add or WorksheetCollection.Insert method. To remove a worksheet from the workbook, use the WorksheetCollection.Remove or WorksheetCollection.RemoveAt method.

For details on how to manage worksheets in a workbook, refer to the Worksheets section of examples.

Example

This example demonstrates how to access worksheets in a workbook. Use the IWorkbook.Worksheets property to get a collection of worksheets contained in a workbook (the WorksheetCollection object).

To get an individual worksheet by its index or name, use the WorksheetCollection.Item property.

using DevExpress.Spreadsheet;
// ...

IWorkbook workbook = spreadsheetControl1.Document;

// Access a collection of worksheets.
WorksheetCollection worksheets = workbook.Worksheets;

// Access a worksheet by its index.
Worksheet worksheet1 = workbook.Worksheets[0];

// Access a worksheet by its name.
Worksheet worksheet2 = workbook.Worksheets["Sheet2"];
See Also