Date: prev next · Thread: first prev next last
2025 Archives by date, by thread · List index


Hi there!

his is going to be a development question, but since it is abut using LibreOffice('s API), i am asking it here.
Please send me elsewhere if this is not the appropriate place.
I was doing some reasearch the last couple of days and also toying with code and have not found a satisfying answer yet.

The short version of my question is:
How can i run `SCFunctionAccess::callFunction` from Python wihout UNO?

The long version:
I have this large legacy application written in Excel which was made compatible with LibreOffice in recent years.
This application is still updated on a regular basis.
Now, there is the need to make this application (or parts of it) available as a web service. As i already have a server running Django providing various web services, i would like to use Python to connect to that application. Translating the functionality of the original app to Python on every update would be quite a pain. I already have that in production for one feature of the application.

Using the UNO bridge via Python seems to work, but loading the Excel file takes about 25s which is unacceptable to be run on each web request. I also tried OpenPyXL which loads the document a few seconds faster, but still needs an unacceptable 20s. Also, the process uses a huge amount of memory: 600 MB compared to 25 MB with UNO (measured by /usr/bin/time -v). And afaik, i can not change cell contents and then have functions like COUNTIF run on the changed contents.

So the current idea is to transpile the Excel file to a Python package which can be repeated every time there is an update to the application. Basically, I have the transpilation part sussed out, the problem is now the implementation of all the LibreOffice/Excel functions, like COUNTIF or exact semantics of e.g. '+' in a LibreOffice context. The hope is that SCFunctionAccess::callFunction (from core/sc/source/ui/unoobj/funcuno.cxx) can do that for me. To be able to use that from Python, i could wrap it using boost::python or swig. Does anyone have experience with wrapping LibreOffice functions? Or maybe ctypes? Which .so file in `/usr/lib/libreoffice/program/` (Debian-based OS) contains that method/class (have not studied the LibreOffice build process intensively yet)? I do not know if ctypes works with C++ libraries, though. In any case, for all these wrappers, I fear, I still would need to load the whole document into an instance of `SCFunctionAccess` which might take too much time.

Thanks for reading this so far and i hope i have made myself clear enough.
Do you reckon wrapping the C++ code for Python is viable?
Or perhaps, there is a totally different approach you can think of?

Thanks in advance,
  Sebastian


--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.