Worksheet Host Item
Applies to |
---|
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office. Document-level projects
Application-level projects
For more information, see Features Available by Application and Project Type. |
The Worksheet host item is a worksheet that exposes events and acts as a container for host controls and Windows Forms controls.
When you create a new document-level customization for Microsoft Office Excel, Visual Studio Tools for Office automatically creates three Worksheet host items in the project. The default names of the worksheets are Sheet1, Sheet2, and Sheet3. If you create an application based on an existing workbook, the number of host items depends on the number of worksheets in the workbook.
Understanding Worksheet Host Items
In the same way you add Windows Forms controls to a Windows form, you can add Windows Form controls and host controls to a Worksheet host item.
In a document-level project, you can add additional Worksheet host items to the project at design time; however, Microsoft.Office.Tools.Excel.Worksheet host items are not automatically created when you add a worksheet programmatically. If you add a worksheet at run time in a document-level project, it will be of the type Worksheet, and cannot contain any host controls or Windows Forms controls.
Starting in Visual Studio 2008 Service Pack 1 (SP1), you can add worksheets at run time in an application-level add-in, and then call the GetVstoObject method of a Worksheet object to get a Worksheet host item. For more information, see Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time.
In Excel projects, the worksheet is the primary vehicle for user interaction. By combining different sets of controls and writing code, you can bind the controls to data, get input from the user, and respond to user actions.
Renaming the Worksheet
In a document-level customization, you can rename the worksheets in the Visual Studio designer, but this only changes the display name of the worksheet. The programmatic name is still the default name of the worksheet. If you rename the worksheet in the Properties window, only the programmatic name is changed.
Events
The events available for the Worksheet host item are:
See Also
Tasks
Excel Add-In Dynamic Controls Sample
Concepts
Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time
Adding Controls to Office Documents at Run Time
Host Items and Host Controls Overview
Programmatic Limitations of Host Items and Host Controls
Other Resources
Change History
Date |
History |
Reason |
---|---|---|
July 2008 |
Added information about using worksheet host items in application-level add-ins. |
SP1 feature change. |