Export (0) Print
Expand All
Expand Minimize

Workbook.Worksheets Property

Gets a Microsoft.Office.Interop.Excel.Sheets collection that represents all the worksheets in the workbook.

Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel (in microsoft.office.tools.excel.dll)

public virtual Sheets Worksheets { get; }

Property Value

A Microsoft.Office.Interop.Excel.Sheets collection that represents all the worksheets in the workbook.

This property does not return macro sheets, charts, or dialog sheets. Use the Sheets property to return those sheets as well as worksheets. You can also use the specialized properties Excel4MacroSheets and Excel4IntlMacroSheets to return macro sheets and the Charts property to return charts.

The following code example uses the Worksheets property to make the second worksheet in the current workbook invisible.

private void HideSecondWorksheet()
{
    Excel.Worksheet worksheet = (Excel.Worksheet)this.Worksheets[2];
    worksheet.Visible = Excel.XlSheetVisibility.xlSheetHidden;
}

Show:
© 2014 Microsoft