Hello everyone,
I’m using the latest version of LibreOffice (25.2.3.2) on Linux, and I’m trying to use a Python macro as a spreadsheet function in Calc — but I haven’t been able to get it to work so far.
Here’s a minimal test script I’m using (just for debugging purposes):
python
def test_func():
return "Hello from Python"
# Expose the function to LibreOffice
g_exportedScripts = (test_func,)
What I’ve tried:
- I placed the file at:
~/.config/libreoffice/4/user/Scripts/python/test.py
- The macro and the function are visible via:
Tools → Macros → Run Macro → My Macros → test → test_func
- I lowered the macro security in:
Tools → Options → LibreOffice → Security → Macro Security → Low
- I fully restarted LibreOffice
The problem:
When I try to use =test_func()
directly in a cell, I get the error #NAME?
.
From what I understand, this means Calc doesn’t recognize the function at all.
I searched in forums, LibreOffice documentation, and even asked ChatGPT — but I still haven’t found a clear explanation or solution. The official documentation on Python macros is really sparse, especially when it comes to using them as spreadsheet functions.
My question:
Has anyone successfully used a Python macro as a Calc formula?
Is it even supported natively, or do I need to use a workaround (like Basic wrappers or UNO services)?
Any pointers or working examples would be greatly appreciated!
Thanks in advance for your help
Loan