davidkent Newbie

Joined: 08 Feb 2012 Posts: 1
|
Posted: Wed Feb 08, 2012 10:17 pm Post subject: CALC: Determine row/column count of Merged Cell by Java |
|
|
I spend time search over internet but did not find any result about sample to determine row/column of Merged Cell, So give you the following Java code may help
sheet is XSpreadsheet , row.col is the cell need to deternime
You may exchange using getCellRangeByPosition by getCellRangeByName if you prefer to use cell Name instead of (row, col)
| Code: | XCellRange xCellRange = sheet.getCellRangeByPosition(col, row, col, row);
com.sun.star.sheet.XSheetCellRange xSCellRange = (com.sun.star.sheet.XSheetCellRange) UnoRuntime.queryInterface(com.sun.star.sheet.XSheetCellRange.class, xCellRange);
com.sun.star.sheet.XSheetCellCursor xCursor = sheet.createCursorByRange(xSCellRange);
xCursor.collapseToMergedArea();
XCellRangeAddressable xCellRangeAddressable = UnoRuntime.queryInterface(XCellRangeAddressable.class, xCursor);
int row_count = xCellRangeAddressable.getRangeAddress().EndRow - xCellRangeAddressable.getRangeAddress().StartRow + 1;
|
Moderation probe1: moved to CODE SNIPPETS section; edited subject; set CODE tags |
|