| View previous topic :: View next topic |
| Author |
Message |
LinuksGuru General User

Joined: 01 Sep 2011 Posts: 5
|
Posted: Wed Sep 28, 2011 1:51 pm Post subject: Please Help - Python UNO Problem |
|
|
Hi !
I have problem with Python and Uno which I cannot solve at the moment. I wrote a test function in Python which obtains and changes cell content in Calc spreadsheet.
Right it is possible to obtain cell content from Python, but it is not possible to change it.
Please look at the code below.
--------------------------------------------------
| Code: | import numpy
import uno, unohelper
def GetCells(n):
oDoc = XSCRIPTCONTEXT.getDocument()
oSheet = oDoc.getSheets().getByName("Cap")
# oSheet is valid object, otherwise Python would throw exception at lines below.
# Doesn't work, nothing happens.
oSheet.getCellByPosition(0, 0).setString("Set String from Python 1")
oSheet.getCellRangeByName("C67").setFormula("=100 + 300")
oSheet.getCellByPosition(3, 68).setValue(100.235)
# Works !
return oSheet.getCellRangeByName("A24").getString() |
--------------------------------------------------
Anyone can explain what could be wrong?
I'm running SuSE 11.4 x64 and LibreOffice 3.4.2 (from stable SuSE repository).
Thanks in advance for any help. |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Thu Sep 29, 2011 12:26 am Post subject: |
|
|
SuSE, Ubuntu and all the other Linux distros do an extremely lousy job trying to "integrate" OOo/LibO into their distributions. In fact there is nothing to integrate. SImply download and install the vanilla packages from the project site openoffice.org or libreoffice.org respectively. Since OOo 2.0.3 I block any distributor's OOo/LibO and everything works just fine.
This is the exact snippet I pasted into a python module and ran in LibO 3.4.3 under Ubuntu. This kind of simple stuff used to work since OOo 1.1.3
| Code: | import uno, unohelper
def GetCells():
oDoc = XSCRIPTCONTEXT.getDocument()
oSheet = oDoc.getSheets().getByIndex(0)
# oSheet is valid object, otherwise Python would throw exception at lines below.
# Doesn't work, nothing happens.
oSheet.getCellByPosition(0, 0).setString("Set String from Python 1")
oSheet.getCellRangeByName("C67").setFormula("=100 + 300")
oSheet.getCellByPosition(3, 68).setValue(100.235)
# Works !
return oSheet.getCellRangeByName("A24").getString()
g_exportedScripts=GetCells,
|
_________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
LinuksGuru General User

Joined: 01 Sep 2011 Posts: 5
|
Posted: Thu Sep 29, 2011 2:02 am Post subject: |
|
|
The reason I'm use SuSE distribution of LibreOffice is quite simple - Python. Standard LibreOffice comes with built-in Python, yet "SuSE integrated" use Python from SuSE.
The application I'm writing is quite complex, and it requires numeric & scientific libraries like numpy and scipy.
With "standard" LibreOffice and its "built-in" Python interpreter it would be a problem.
Please correct me if I'm wrong. |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Thu Sep 29, 2011 2:16 am Post subject: |
|
|
Anyhow, this is a SuSE question. They messed it up again. _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
LinuksGuru General User

Joined: 01 Sep 2011 Posts: 5
|
Posted: Thu Sep 29, 2011 11:55 pm Post subject: |
|
|
| Villeroy, what happened with the forum on OpenOffice.org? It seems to be down for several days. |
|
| Back to top |
|
 |
LinuksGuru General User

Joined: 01 Sep 2011 Posts: 5
|
Posted: Fri Sep 30, 2011 12:27 am Post subject: |
|
|
Villeroy, once you have posted a link on OpenOffice.org forum to sample code which pass array between LibO Basic and Python. Since OpenOffice.org forum is down, and Google cache for whatever reason don't display a copy, can you please post this link or sample here?
Thanks in advance. |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
|
| Back to top |
|
 |
|