RowCollection Class |
Namespace: Aspose.Words.Tables
The RowCollection type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | Count |
Gets the number of nodes in the collection.
(Inherited from NodeCollection.) |
![]() ![]() | Item |
Retrieves a Row at the given index.
|
Name | Description | |
---|---|---|
![]() ![]() | Add |
Adds a node to the end of the collection.
(Inherited from NodeCollection.) |
![]() ![]() | Clear |
Removes all nodes from this collection and from the document.
(Inherited from NodeCollection.) |
![]() ![]() | Contains |
Determines whether a node is in the collection.
(Inherited from NodeCollection.) |
![]() | Equals | (Inherited from Object.) |
![]() | GetEnumerator | (Inherited from NodeCollection.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() ![]() | IndexOf |
Returns the zero-based index of the specified node.
(Inherited from NodeCollection.) |
![]() ![]() | Insert |
Inserts a node into the collection at the specified index.
(Inherited from NodeCollection.) |
![]() ![]() | Remove |
Removes the node from the collection and from the document.
(Inherited from NodeCollection.) |
![]() ![]() | RemoveAt |
Removes the node at the specified index from the collection and from the document.
(Inherited from NodeCollection.) |
![]() ![]() | ToArray |
Copies all rows from the collection to a new array of rows.
|
![]() | ToString | (Inherited from Object.) |
Document doc = new Document(MyDir + "Tables.docx"); // Here we get all tables from the Document node. You can do this for any other composite node // which can contain block level nodes. For example you can retrieve tables from header or from a cell // containing another table (nested tables) TableCollection tables = doc.FirstSection.Body.Tables; // We can make a new array to clone all of the tables in the collection Assert.AreEqual(2, tables.ToArray().Length); // Iterate through all tables in the document for (int i = 0; i < tables.Count; i++) { // Get the index of the table node as contained in the parent node of the table Console.WriteLine($"Start of Table {i}"); RowCollection rows = tables[i].Rows; // RowCollections can be cloned into arrays Assert.AreEqual(rows, rows.ToArray()); Assert.AreNotSame(rows, rows.ToArray()); // Iterate through all rows in the table for (int j = 0; j < rows.Count; j++) { Console.WriteLine($"\tStart of Row {j}"); CellCollection cells = rows[j].Cells; // RowCollections can also be cloned into arrays Assert.AreEqual(cells, cells.ToArray()); Assert.AreNotSame(cells, cells.ToArray()); // Iterate through all cells in the row for (int k = 0; k < cells.Count; k++) { // Get the plain text content of this cell string cellText = cells[k].ToString(SaveFormat.Text).Trim(); // Print the content of the cell Console.WriteLine($"\t\tContents of Cell:{k} = \"{cellText}\""); } Console.WriteLine($"\tEnd of Row {j}"); } Console.WriteLine($"End of Table {i}\n"); }