Ask Your Question
0

Getting started writing Python macros and UDFs

asked 2019-06-09 22:14:00 +0100

ihf gravatar image

updated 2019-06-09 23:39:16 +0100

Can anyone point a new user of Libreoffice (v6.2.4.2) to a tutorial on using Python in conjunction with Calc? I would like to be able to write macros and UDFs in Python. I started with this tutorial http://christopher5106.github.io/office/2015/12/06/openoffice-libreoffice-automate-your-office-tasks-with-python-macros.html but it must be for an earlier distribution as it refers to an included python interpreter.

edit retag flag offensive close merge delete

Comments

This is a questions-and-answers site for LibreOffice users. Yours is about development and you will probably get much quicker answers if you ask at #libreoffice-dev at FreeNode or here.

gabix gravatar imagegabix ( 2019-06-09 23:04:13 +0100 )edit

@gabix

I would simply consider this as nothing more than dealing with macros. I consider development more in line with LO core and SDK. Many questions on this site have already dealt with this.

Ratslinger gravatar imageRatslinger ( 2019-06-09 23:14:36 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-06-09 22:42:50 +0100

Ratslinger gravatar image

updated 2019-06-09 22:44:56 +0100

Hello,

The link you noted worked last time I tried it. It is for interactive use. Can also do this with some IDE's if set up correctly.

But for your question, see:

https://wiki.documentfoundation.org/M...

and

https://wiki.documentfoundation.org/M...

and

https://help.libreoffice.org/6.3/en-U...

for starters. You can also search this site using keyword Python and find a number of posts and examples.

edit flag offensive delete link more

Comments

@ihf Please note Python is included in LO releases through current. If you are having an issue with something please be specific.

Personally preferred to use PyCharm when dealing interactively. I set this up based upon information provided in links in answer.

Ratslinger gravatar imageRatslinger ( 2019-06-09 23:37:29 +0100 )edit

That link refers to using the python interpreter found in the LibreOffice.app directory though there does not appear to be a python instance there. I will check out the links you provided though with a quick perusal I did not see an example of a UDF or a Calc macro written in Python.

ihf gravatar imageihf ( 2019-06-09 23:44:36 +0100 )edit

@ihf

It appears you may not be looking in the correct place for Python in LO. You have not specified your OS but on my Linux Ubuntu 18.04 using LO v6.2.0.3 here it is (from terminal):

$ /opt/libreoffice6.2/program/python
Python 3.5.5 (default, Jan 24 2019, 09:05:38) 
[GCC 7.3.1 20180303 (Red Hat 7.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

This is what I would use in the link you provided. Again I prefer to use PyCharm for interactive use. You can also write Python macros simply using a text editor but then no interaction.

As for a specific step-by-step, the link you have is probably the most complete.

Ratslinger gravatar imageRatslinger ( 2019-06-10 00:11:23 +0100 )edit

This has more which may interest you -> LibreOfficeDev Python script help

Ratslinger gravatar imageRatslinger ( 2019-06-10 00:24:46 +0100 )edit

You also asked for sample code and stated in answer search in this forum. Here are just a couple of Calc macros:

https://ask.libreoffice.org/en/questi...

https://ask.libreoffice.org/en/questi...

Ratslinger gravatar imageRatslinger ( 2019-06-10 00:57:00 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-06-09 22:14:00 +0100

Seen: 184 times

Last updated: Jun 09