Поделиться через


Work with worksheets

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The Worksheet and Worksheet classes contain the methods and properties you use to perform tasks with worksheets.

Task Procedure
Add a new worksheet to a workbook. How to: Programmatically add new worksheets to workbooks
Make a copy of a worksheet in a specified location in the workbook. How to: Programmatically copy worksheets
Delete a specified worksheet. How to: Programmatically delete worksheets from workbooks
Move the user's selection to a specified worksheet. How to: Programmatically select worksheets
Iterate through the collection of all worksheets. How to: Programmatically list all worksheets in a workbook
Preview and print a worksheet. How to: Programmatically print worksheets
Move a worksheet to a new location in a workbook. How to: Programmatically move worksheets within workbooks
Change the visibility of one or more worksheets. How to: Programmatically hide worksheets
Lock all or part of a worksheet so it cannot be edited. How to: Programmatically protect worksheets
Remove the lock from a worksheet so it can be edited. How to: Programmatically remove protection from worksheets
Add and delete comments. How to: Programmatically add and delete worksheet comments
Show or hide all comments. How to: Programmatically display worksheet comments
Create groups in worksheets. How to: Programmatically group rows in a worksheet
Make a row bold only when it contains a selected cell. How to: Programmatically change formatting in worksheet rows containing selected cells
Copy data and formatting across worksheets. How to: Programmatically copy data and formatting across worksheets
Check spelling in worksheets. How to: Programmatically check spelling in worksheets
Sort data in named ranges and list objects. How to: Programmatically sort data in worksheets

For more information about Excel tasks and the Excel object model, see Excel object model overview.

In some cases, the ways that you perform these tasks in VSTO Add-ins is different from the ways that you perform them in document-level customizations.

See also