I am trying to determine how many cells are merged horizontally in a table, but cell.getCellFormat().getHorizontalMerge() always returns CellMerge.NONE, even when it comes across merged cells. getVerticalMerge() appears to work fine.
com.aspose.words.Document asposeDoc = new com.aspose.words.Document("testMergedCells.docx");
Table table = (Table)asposeDoc.getChild(NodeType.TABLE, 0, true);
int cellNum = 0;
for (Row row : table.getRows()) {
for (Cell cell : row.getCells()) {
cellNum++;
boolean isHorizontallyMerged = cell.getCellFormat().getHorizontalMerge() != CellMerge.NONE;
boolean isVerticallyMerged = cell.getCellFormat().getVerticalMerge() != CellMerge.NONE;
String msg = "Cell " + cellNum;
if(isHorizontallyMerged) {
msg += " Horizontally Merged";
}
if(isVerticallyMerged) {
msg += " Vertically Merged";
}
System.out.println(msg);
}
}
Any help much appreciated, thank you.