I want to be able to create a CALC-Function in BASIC as an extension and distribute it

When you create a LibreOffice extension, a library is created and stored there, not a Standard macro.

The standard macro in My Macros is from a Calc sheet
= functionName(param)
, you can call it, but you can’t call the one in the library.

I would like to create a function as an extension and be able to distribute it.
It seems to me that I have to write the code in Python instead of BASIC.
Is there a better way?

https://extensions.libreoffice.org/en/extensions/show/27434

XLOOKUP used to call the IDL compiler (which comes with LibreOffice-SDK) to create the interface and implement it in Python.

Does this mean that it cannot be used in BASIC? ?

This question, when asked about writing in Basic as opposed to Python, is worded in a provocative way (because, indeed, comparing Basic language with Python, calling Basic “better” is at least questionable).

The real problem is: implementing a plugin function requires implementing a UNO interface. Python can do it out of the box. Basic has no easy way of doing that - but you can (ab)use CreateUnoListener function to implement any UNO interface.

In general - if you really must use Basic, then still consider Python - at least for the framework; and if unavoidable, call your Basic functions from Python shim functions.

1 Like

There is already an extension developed on XLOOKUP
https://extensions.libreoffice.org/en/extensions/show/27434

1 Like
  • We can write sheet functions in Basic. They only work if stored in the “Standard” library.
  • We can distribute Basic libraries wrapped in extensions, but not the “Standard” library.
    Conclusion: We can not distribute sheet functions written in Basic wrapped in extensions.