What is a Worksheet?
A worksheet is a type of Sheet and the primary working surface in a Workbook. It organizes data in a grid of rows and columns, where each intersection forms a cell. A workbook can contain multiple worksheets with related content, and only one worksheet is active at a time.
Use a worksheet when you need to store values, formulas, formatting, hyperlinks, named ranges, and worksheet-specific view settings inside a spreadsheet document.
In SpreadProcessing,
Worksheetis the onlySheettype that is currently supported.
How a Worksheet Fits in a Workbook
A Workbook acts as the container for one or more worksheets. Each worksheet holds its own grid data, formatting, names, protection settings, and view state. This structure lets you separate related information into multiple tabs while keeping the content in a single spreadsheet document.
Worksheet Dimensions
Each worksheet provides a grid of 1,048,576 rows and 16,384 columns, which matches the capacity of an Excel worksheet. Rows use zero-based numeric indexes, and columns use zero-based column indexes. In a spreadsheet UI, rows are labeled with numbers and columns are labeled with letters from A through XFD.
Key Features
The following table summarizes the main tasks that you can perform on a worksheet:
| Area | What You Can Do | Learn More |
|---|---|---|
| Cells | Insert, update, format, and delete cell content through the Cells property. | What Is a Cell? |
| Rows and columns | Insert, remove, resize, and manage worksheet structure. | Working with Rows and Columns |
| Named ranges | Create and manage named ranges through the Names property. | Named Ranges |
| Hyperlinks | Add links to web pages, workbook locations, or email addresses. | Hyperlinks |
| Find and replace | Search for and replace text or numbers in worksheet content. | Find and Replace |
| Protection | Restrict editing and control which actions remain available. | Worksheet Protection |
| View state | Control frozen panes, active cell, selection, and zoom. | View State |
| Visibility | Hide worksheets without removing them from the workbook. | Sheets Visibility |
Each worksheet also exposes several features that help you organize and query spreadsheet content:
- Cells: Each worksheet contains cells that hold values, formulas, and formatting.
- Rows and columns: Worksheet structure is organized into rows and columns that you can resize, insert, remove, and format.
- Named ranges: The
Namesproperty exposes aNameCollectionthat lets you define reusable worksheet references. - Hyperlinks: A worksheet can contain links to websites, workbook locations, and email addresses.
- Find and replace: You can search worksheet content and replace matching values.
- Protection: You can prevent unwanted edits while leaving selected cells unlocked.
- View state: You can control worksheet-specific display settings such as the active cell, selection, frozen panes, and zoom.
- Visibility: You can hide a worksheet without deleting it from the workbook.
How to Get the Used Cell Range
Use the UsedCellRange property when you need the smallest range that starts at A1 and contains all cells with data or formatting. Use GetUsedCellRange() when you want to narrow the result to cells that match specific property definitions.
The GetUsedCellRange() overload accepts an IEnumerable<IPropertyDefinition> parameter and returns only the used cells for those definitions.
The following example gets the used cell range for cells that contain a value.
Example 1: Get the Used Cell Range of Cells with a Value
CellRange result = worksheet.GetUsedCellRange(new IPropertyDefinition[] { CellPropertyDefinitions.ValueProperty });
For more information and additional examples, see Iterating Used Cells.
Next Steps
After you understand the role of a worksheet, continue with the article that matches your next task:
- Read What Is a Cell? to work with worksheet content.
- Read Working with Rows and Columns to manage worksheet structure.
- Read View State to control how a worksheet appears.
- Read Worksheet Protection to restrict editing.