WorkbookBase.Sheets 属性

获取一个 Microsoft.Office.Interop.Excel.Sheets 集合,该集合表示工作簿中的所有工作表。

命名空间:  Microsoft.Office.Tools.Excel
程序集:  Microsoft.Office.Tools.Excel.v4.0.Utilities(在 Microsoft.Office.Tools.Excel.v4.0.Utilities.dll 中)

语法

声明
Public ReadOnly Property Sheets As Sheets
    Get
public Sheets Sheets { get; }

属性值

类型:Microsoft.Office.Interop.Excel.Sheets
Microsoft.Office.Interop.Excel.Sheets 集合,表示工作簿中的所有工作表。

备注

该集合包括工作簿中的工作表、图表、对话框表和宏表。

示例

下面的代码示例使用 Sheets 属性显示工作簿中工作表的数量。

此示例针对的是文档级自定义项。

Private Sub DisplayNumberOfSheets()
    MsgBox("There are " & Me.Sheets.Count & _
        " sheets in this workbook.")
End Sub
private void DisplayNumberOfSheets()
{
    MessageBox.Show("There are " + this.Sheets.Count +
        " sheets in this workbook.");
}

.NET Framework 安全性

请参见

参考

WorkbookBase 类

Microsoft.Office.Tools.Excel 命名空间