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

2 Likes

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: https://onesheep.org/scripting-libreoffice-python/
[edit: by @karolus ] the Link is dead now!

@JannieT1: some nice points :wink:

please correct the missing Indentation in dev.py 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!

Googling for it brought it up: Scripting LibreOffice with Python | OneSheep

Fwiw, that link is dead but the page is available in the WayBackMachine.

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

Hallo!
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:
tuturial
Start
not so hard as it looks
best available answer :wink:

1 Like

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.

1 Like

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 https://wiki.documentfoundation.org/Macros/Python_Design_Guide, or Python Scripts, or the talks you gave on our conferences you gave: in Almeria, online.

@mikekaganski,
Indeed, thanks for having corrected me.