[Solved] How to get range of merged cells

Creating a macro - Writing a Script - Using the API

[Solved] How to get range of merged cells

Postby VBandOoffice » Thu Jan 17, 2019 4:16 pm

Hi all,
I need to know, weather some cells of a spreadsheet are merged together or not.
If I define a range and look to isMerged or use getIsMerged, then I get TRUE, even if only the first two cells from ten cells are merged together.
Only if there are no cells at all merged, isMerged will be read FALSE.

Do anyone know about this - and how to work around? I'm using LibreOffice 6.1.4 and Windows7

Best regards,
VBandOoffice
Last edited by VBandOoffice on Tue Jan 22, 2019 3:46 pm, edited 1 time in total.
LibreOffice 5.4, Windows 7, VB.net 2010
VBandOoffice
 
Posts: 25
Joined: Tue Jul 31, 2018 10:11 am

Re: How to get range of merged cells

Postby Lupp » Thu Jan 17, 2019 5:10 pm

On Windows 10: LibreOffice 6.2 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2479
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: How to get range of merged cells

Postby VBandOoffice » Fri Jan 18, 2019 10:28 am

Hello Lupp,

with the code from Villeroy (Sub fillMergedAreas(oRange, oRanges)) I only get all StartCells of merged cells correctly, but the range is not matching the real merged range.
If there are some unmerged cells between the merged ranges, I will not detect them.

Some Ideas why? - And how to get the real merged range?

Best regards,
VBandOoffice
LibreOffice 5.4, Windows 7, VB.net 2010
VBandOoffice
 
Posts: 25
Joined: Tue Jul 31, 2018 10:11 am

Re: How to get range of merged cells

Postby Villeroy » Fri Jan 18, 2019 5:28 pm

In the attached file (selectMerged.ods) you find a function that returns the merged region of a start cell.
In fact the macro in that document selects all the regions. The code snippet in the other posting is faster since it does not do that.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 26734
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to get range of merged cells

Postby JeJe » Fri Jan 18, 2019 11:02 pm

My oops.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 508
Joined: Wed Mar 09, 2016 2:40 pm

Re: How to get range of merged cells

Postby VBandOoffice » Tue Jan 22, 2019 3:45 pm

Hi all,

it works!

Thank you Villeroy!

Best regards to all,
VBandOoffice
LibreOffice 5.4, Windows 7, VB.net 2010
VBandOoffice
 
Posts: 25
Joined: Tue Jul 31, 2018 10:11 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 10 guests