Ask Your Question
0

Calc merged cell macro returns false - bug or intentional?

asked 2018-11-13 00:24:40 +0100

UserRyan gravatar image

updated 2018-12-10 20:21:48 +0100

When getting the merged properties of a cell (isMerged), only the first cell returns True. Not sure if this is a bug that should be reported or if there is a way around this.

Libreoffice 6.1.0.3 on CentOS

Ex:

         +---------------+----------------+
         |     A         |      B         |
+------------------------+----------------+
|   1    |  Merged Cell                   |
+------------------------+----------------+
|   2    |  Normal       |   Normal       |
+--------+---------------+----------------+

The spreadsheet generated the following results:

getCellRangeByName("$A$1").getIsMerged -> True
getCellRangeByName("$A$2").getIsMerged -> False
getCellRangeByName("$B$1").getIsMerged -> False  (why??!!)
getCellRangeByName("$B$2").getIsMerged -> False

Any hacks to get around this?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2018-11-13 07:12:38 +0100

Hello @UserRyan. Thanks for asking.

I think this is expected behavior, cause IsMerged property is set to True only for the cell that remains visible after merging - first cell of the range. Other cells are just hidden under this cell with their IsMerged property set to False. If you want to get the whole merged range, you can use Cursor for this purpose.

Assume you find that cell with property IsMerged set to True is cell A1 on the first sheet of document:

oSheet = ThisComponent.GetSheets().GetByIndex(0)    
oMergedCell = oSheet.getCellRangeByName("A1")
oCursor = oSheet.CreateCursorByRange(oMergedCell)
oCursor.CollapseToMergedArea()

So now oCursor range is $Sheet1.$A$1:$B$1

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-13 00:24:40 +0100

Seen: 70 times

Last updated: Dec 10 '18