Finding the Index of Table Elements

Finding the Index of Table in a Document

The following code example shows how to retrieve the index of a table in the document.

// 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.

// 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.

// 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);
}