Finding the Index of Table Elements
Contents
[
Hide
]
Finding the index of any node involves gathering all child nodes of the element’s type from the parent node then using the NodeCollection.indexOf(com.aspose.words.Node) method to find the index of the desired node in the collection.
Finding the Index of Table in a Document
The following code example shows how to retrieve the index of a table in the document.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
public static void findIndexOfTableInADocument(Document doc, Table table) { | |
NodeCollection allTables = doc.getChildNodes(NodeType.TABLE, true); | |
int tableIndex = allTables.indexOf(table); | |
System.out.println("Table Index: " + tableIndex); | |
} |
Finding the Index of a Row in a Table
The following code example shows how to retrieve the index of a row in a table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
public static void findIndexOfARowInATable(Table table, Row row) { | |
int rowIndex = table.indexOf(row); | |
System.out.println("Row Index: " + rowIndex); | |
} |
Finding the Index of a Cell in a Row
The following code example shows how to retrieve the index of a cell in a row.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-Java | |
public static void findIndexOfACellInARow(Row row, Cell cell) { | |
int cellIndex = row.indexOf(cell); | |
System.out.println("Cell Index: " + cellIndex); | |
} |