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
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 命名空間