How to: Access a Worksheet
- 2 minutes to read
You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.
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; // Access a worksheet by its name. Worksheet worksheet2 = workbook.Worksheets["Sheet2"];
A worksheet index is zero-based. It specifies the worksheet position within a collection. The worksheet name is unique within the collection, and is shown on a worksheet tab. The image below shows worksheet indexes and names in a workbook that is opened in Microsoft® Excel®.