阿克塞尔,
这为我指明了正确的方向,但我应该注意 XCell 接口没有 getPropertyValue 方法。相反,需要获取 XCell 对象的 XPropertySet。这是有效的完整代码:
public void mergeCells(int startColumn, int startRow, short endColumn, short endRow) {
if (endRow == 0 && endColumn == 0) {
return;
}
XCell xCell = getCell(column, row); //Custom method to get cell
XPropertySet props = null;
try {
props = (XPropertySet) FileManager.getOOoUnoRuntimeQueryInterface(XPropertySet.class, xCell);
} catch (Exception ex) {
// Do error stuff
}
XTextTableCursor textTableCursor = null;
String cellName = null;
try {
cellName = props.getPropertyValue("CellName").toString();
} catch (Exception ex) {
// Do error stuff
}
try {
textTableCursor = xTextTable.createCursorByCellName(cellName);
textTableCursor.goRight(endColumn, true);
textTableCursor.goDown(endRow, true);
textTableCursor.mergeRange();
} catch (Exception ex) {
// Do error stuff
}
}