Detailed tutorial regarding LibreOffice to Python macro writing, especially for Calc

Re. python and basic and frequency of languages: please note that the raspberry pi is a very popular credit card computer, introduced around 2012 in high school classes, now used around the world and with python as the default programming language. So chances are strong that a population of students, and others!, grow up with python nowadays, rather than basic.

A tutorial here : Interface-oriented programming in OpenOffice / LibreOffice : automate your office tasks with Python Macros

1 Like

Yes, this is by far the best tutorial on Python macros in LibreOffice, and it should be given more prominence in the official documentation. I can recommend it wholeheartedly to anyone who needs to start programming LibreOffice with Python macros. Thank you for writing this.

Thank you! This looks very promising :slight_smile:

I was frustrated about the same thing as the OP, so made the time to publish my journey notes here:
[edit: by @karolus ] the Link is dead now!

@JannieT1: some nice points :wink:

please correct the missing Indentation in and generally please follow the strong Convention of exactly four spaces per Indentation-level.

Have a look my answer in this thread

the link doesn’t work (obviously after 3 years…). Do you still have a copy of it? I’m very interested in it. Thanks!

I made two libreoffice macros on python to rename and delete files. I hope It helps. Here is the link: GitHub - albcunha/libreoffice_macros: Python Script that inserts two macros for LibreOffice/Open Office: Rename files and Delete Files

How to start?
Currently your on the Stage:

  • no programming skills
  • no skills about this huge 200 MB Program nor its complicated Api

I’m only can give some advice: Start learning Python independent from Libreffice.
at some day in the Future you will be able to work with the “pieces spread over the web

some links:
not so hard as it looks
best available answer :wink:

I do know Python loosely speaking. However, I have not found anything specific regarding Python used in conjunction to LibreOffice. Knowing Python can’t make it read LibreOffice sheets in its particular format can it?

Of Course with python you can also read|write .odf in general inclusive .ods in detail without any soffice at hand.
this thirdparty-tool

A simple Python Macro in LibreOffice 4.0 – Lakmal's Blog

You link provide no new informations, the HelloWorld-example is already included in ...libreoffice/share/Scripts/python/...

this is a good example and exemplifies my impression that the LibreOffice flavor of Python is fairly unPythonic dialect of Java. Would help to have a reference of what are the major objects/methods to invoke to get started, the equivalent in LO Basic of ThisComponent ThisDatabaseDocument and dbg_methods, etc.

Updating this old and maybe outdated but cross-referenced Q&A with a pointer to my (occasionally maintained) LibreOffice Scripting link collection.

Check my profile in this forum for extra Python information

Alain: “Check my profile” isn’t the best way to advertise your great work you did on scripting documentation for LibreOffice, being one of the initiators of LibreOffice Macro Team. Better provide a good list of links to stuff like, or Python Scripts, or the talks you gave on our conferences you gave: in Almeria, online.

Indeed, thanks for having corrected me.

Tutolibro – Series – in the second block - LibreOffice Calc & Python Macro Tutorials

Some examples exactly for: NOT howto do

data = (2,1,3)
output = tuple(entry for entry in reversed(data)) #no, no ,no!
# use simply:
output = tuple( reversed(data))
1 Like