WorksheetBase.Parent Property

 

Gets the parent object for the worksheet.

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

public object Parent { get; }

Property Value

Type: System.Object

The parent object for the worksheet.

The following code example uses the Parent property to determine whether the current WorksheetBase has a parent. If the current WorksheetBase has a parent, then name of the parent workbook is displayed.

This example is for a document-level customization.

private void DisplayParent()
{
    if (this.Parent != null)
    {
        Excel.Workbook book = (Excel.Workbook)this.Parent;
        MessageBox.Show("The parent workbook for this worksheet is: " + 
            book.Name);
    }
    else
    {
        MessageBox.Show("This worksheet has no parent.");
    }
}
Return to top
Show: