[Solved] How to split cells by API

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Palchaque
Posts: 7
Joined: Fri Dec 12, 2014 11:05 am

[Solved] How to split cells by API

Post by Palchaque »

Sup, I need some help. I use oo api to automatical export data to excel (from 1c, but you dont know what is it, and its cool to you). But i have some problem - i cannot split/merge cells range. I can take the cells range, changes its colors and values what i need, formats etc, but cannot split it from one. Please, can you give some example for dummies :knock: . Much thank you.

And sorry for my bad english :?
Last edited by Hagar Delest on Fri Dec 12, 2014 11:44 pm, edited 1 time in total.
Reason: tagged [Solved].
LibreOffice 4.2 with WinXP sp2
User avatar
RoryOF
Moderator
Posts: 35223
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: How to split cells by api

Post by RoryOF »

Are you looking to split a cell (i.e, unmerge it) back to its components, or to break data in a cell up into separate components. If this latter, what are the criteria for breaking up the data?
Apache OpenOffice 4.1.16 on Xubuntu 24.04.4 LTS
Palchaque
Posts: 7
Joined: Fri Dec 12, 2014 11:05 am

Re: How to split cells by api

Post by Palchaque »

I need to merge cells, i dont care about data in it write now. I need to merge some cells to one, then give it a value.
LibreOffice 4.2 with WinXP sp2
FJCC
Moderator
Posts: 9631
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to split cells by api

Post by FJCC »

Code: Select all

oSheets = ThisComponent.getSheets()
oSheet = oSheets.getByName("Sheet1")
oCellRange = oSheet.getCellRangeByName("A1:A3")
oCellRange.merge(True)
I haven't had time to explore what the boolean argument does in the merge() function.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Palchaque
Posts: 7
Joined: Fri Dec 12, 2014 11:05 am

Re: How to split cells by api

Post by Palchaque »

FJCC wrote:

Code: Select all

oSheets = ThisComponent.getSheets()
oSheet = oSheets.getByName("Sheet1")
oCellRange = oSheet.getCellRangeByName("A1:A3")
oCellRange.merge(True)
I haven't had time to explore what the boolean argument does in the merge() function.
Thank you! It works :super:
LibreOffice 4.2 with WinXP sp2
User avatar
MTP
Volunteer
Posts: 1620
Joined: Mon Sep 10, 2012 7:31 pm
Location: Midwest USA

Re: How to split cells by api

Post by MTP »

FJCC wrote:I haven't had time to explore what the boolean argument does in the merge() function.
.merge(False) splits merged cells.
.merge(True) merges cells, but only if none of the cells in the range are merged. If A1:A2 is merged, then you select A1:B2 and try to merge it, there will be no effect. The macro has to select A1:A2, unmerge them, then select A1:B2 and merge it. Kind of annoying.
OpenOffice 4.1.1 on Windows 10, HSQLDB 1.8 split database
FJCC
Moderator
Posts: 9631
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: How to split cells by api

Post by FJCC »

Thanks!
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Post Reply