NamedRange.ListHeaderRows Property

Gets the number of header rows for the NamedRange control.

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

Syntax

'Declaration
ReadOnly Property ListHeaderRows As Integer
int ListHeaderRows { get; }

Property Value

Type: System.Int32
The number of header rows for the NamedRange control.

Examples

The following code example creates a NamedRange and then displays a message that shows the number of header rows in the NamedRange.

This example is for a document-level customization.

Private getHeadersRange As Microsoft.Office.Tools.Excel.NamedRange

    Private Sub GetNumberOfHeaderRows()
        Me.Range("A1").Value2 = "Row 1" 
        Me.Range("B1").Value2 = "Row 2" 
        Me.Range("C1").Value2 = "Row 3" 

        Me.Range("A2", "A5").Value2 = 10
        Me.Range("B2", "B5").Value2 = 20
        Me.Range("C2", "C5").Value2 = 30

        getHeadersRange = Me.Controls.AddNamedRange( _
            Me.Range("A1", "C5"), "getHeadersRange")

        MessageBox.Show("The NamedRange contains " & _
            getHeadersRange.ListHeaderRows & " header row.")
    End Sub
Microsoft.Office.Tools.Excel.NamedRange getHeadersRange;
private void GetNumberOfHeaderRows()
{
    this.Range["A1"].Value2 = "Row 1";
    this.Range["B1"].Value2 = "Row 2";
    this.Range["C1"].Value2 = "Row 3";

    this.Range["A2", "A5"].Value2 = 10;
    this.Range["B2", "B5"].Value2 = 20;
    this.Range["C2", "C5"].Value2 = 30;

    getHeadersRange = this.Controls.AddNamedRange(
        this.Range["A1", "C5"], "getHeadersRange");

    MessageBox.Show("The NamedRange contains " +
        getHeadersRange.ListHeaderRows + " header row.");
}

.NET Framework Security

See Also

Reference

NamedRange Interface

Microsoft.Office.Tools.Excel Namespace