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

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.

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

@flywire:
Some examples exactly for: NOT howto do
https://tutolibro.tech/2021/05/07/python-libreoffice-reverse-the-order-of-cells-content-from-a-cell-range/

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

@karolus Why don’t you post that comment on the blog where people will see it, and hopefully the author might fix it?

Edit: OK I understand from your comment below comments aren’t displayed until accepted.

@karolus Why don’t you post that comment on the blog where people will see it, and hopefully the author might fix it?

@flywire: thats already done!

1 Like