Udostępnij za pośrednictwem


Worksheet Class (2007 System)

Represents a worksheet that exposes events and acts as a container for controls in Visual Studio Tools for Office projects for Microsoft Office Excel.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public Class Worksheet _
    Inherits EntryPointBindableComponentBase _
    Implements ISupportInitializeControl, ISupportInitialize
'Usage
Dim instance As Worksheet
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class Worksheet : EntryPointBindableComponentBase, ISupportInitializeControl, 
    ISupportInitialize
[PermissionSetAttribute(SecurityAction::Demand, Name = L"FullTrust")]
public ref class Worksheet : public EntryPointBindableComponentBase, 
    ISupportInitializeControl, ISupportInitialize
public class Worksheet extends EntryPointBindableComponentBase implements ISupportInitializeControl, ISupportInitialize

Remarks

The Microsoft.Office.Tools.Excel.Worksheet class is the base class for worksheet host items in Visual Studio Tools for Office projects. The Microsoft.Office.Tools.Excel.Worksheet class provides the same members as the Worksheet class in the Excel primary interop assembly, but it adds the following features:

  • Controls property. Use this property to add managed controls to an Excel worksheet, or remove controls, at run time.

  • InnerObject property. Use this property to get the underlying Worksheet object for a Microsoft.Office.Tools.Excel.Worksheet host item.

  • GetAutomationObject method. Override this method to expose a class in your project to VBA code in the worksheet.

  • Document-level events, such as ActivateEvent and Change, that are provided only at the application level in the Excel object model. That is, in the Excel object model, these events are defined in the Application class rather than the Worksheet class.

For more information about the role the Microsoft.Office.Tools.Excel.Worksheet class plays in Visual Studio Tools for Office projects, see Host Items and Host Controls Overview and Worksheet Host Item.

Creating Worksheet Host Items

In application-level projects created by using Visual Studio 2008 Service Pack 1 (SP1), you can create Microsoft.Office.Tools.Excel.Worksheet objects programmatically by using the GetVstoObject method of any Worksheet object. For more information, see Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time.

In document-level projects, you cannot create a Microsoft.Office.Tools.Excel.Worksheet object programmatically. Instead, use one of the Sheetn classes to programmatically access the worksheet in your project. Visual Studio generates these classes in your project at design time. Each Sheetn class derives from the Microsoft.Office.Tools.Excel.Worksheet class, and is instantiated automatically by the Visual Studio Tools for Office runtime when the end user opens the workbook. For more information, see Programming Document-Level Customizations.

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Tools.Office.RemoteComponent
    Microsoft.VisualStudio.Tools.Office.EntryPointComponentBase
      Microsoft.VisualStudio.Tools.Office.EntryPointBindableComponentBase
        Microsoft.Office.Tools.Excel.Worksheet

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Worksheet Members

Microsoft.Office.Tools.Excel Namespace

Other Resources

Host Items and Host Controls Overview