Export (0) Print
Expand All

ListObject.ListRows Property

Gets a ListRows object that represents all the rows of data in the ListObject control.

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

ListRows ListRows { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.ListRows
A ListRows object that represents all the rows of data in the ListObject control.

The ListRows object returned does not include the header, Total, or Insert rows.

To delete any items from this collection, do not use the Delete method of the item. Use the Delete method of the range of the item to delete the item; for example ListRows.Item(1).Range.Delete().

The following code example creates a ListObject, gets the collection of rows, and then displays a message showing how many rows the ListObject contains.

This example is for a document-level customization.

private void ListObject_ListRows()
{
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(
        this.Range["A1", "C4"], "list1");

    Excel.ListRows list1Rows = list1.ListRows;
    MessageBox.Show("The list object contains " +
        list1Rows.Count.ToString() + " rows.");
}

Show:
© 2014 Microsoft