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

Workbook.Worksheets Property

Gets a collection of worksheets contained in the workbook.

You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use this property in production code.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Docs.v18.2.dll

Declaration

public WorksheetCollection Worksheets { get; }

Property Value

Type Description
WorksheetCollection

A WorksheetCollection object that is a collection of worksheets.

Remarks

A workbook consists of one or more worksheets that are stored within the WorksheetCollection collection returned by the Worksheets property. Use members of the WorksheetCollection object to manage a workbook’s set of worksheets. For example, you can access an individual worksheet by it’s name or index, add a new worksheet, remove an existing worksheet, assign an active worksheet, etc.

For more examples on how to manage worksheets, see the Worksheets section.

Example

This example demonstrates how to access worksheets in a workbook. Use the Workbook.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;
// ...

Workbook workbook = new Workbook();

// 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"];

The following code snippets (auto-collected from DevExpress Examples) contain references to the Worksheets property.

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.

Implements

See Also