OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

CALC: Determine row/column count of Merged Cell by Java

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets
View previous topic :: View next topic  
Author Message
davidkent
Newbie
Newbie


Joined: 08 Feb 2012
Posts: 1

PostPosted: Wed Feb 08, 2012 10:17 pm    Post subject: CALC: Determine row/column count of Merged Cell by Java Reply with quote

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
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Code Snippets All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group