Using SCFunctionAccess::callFunction from Python

Sebastian Henschel sebastian.henschel at passiv.de
Tue Mar 11 10:07:44 UTC 2025


Hello again!

Am 07.03.25 um 08:37 schrieb Sebastian Henschel:
> Am 06.03.25 um 15:17 schrieb Noel Grandin:
>> On 3/6/2025 11:45 AM, Sebastian Henschel wrote:
>>>
>>> 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.
>>
>> My first though, would be o load the Excel file once, via LibreOffice, 
>> when your Django server starts up.
>> And then have each web-request-call talk to that shared instance of 
>> LibreOffice via the Python UNO API.
>>
>> Then it would also be able to modify the contents of the Excel file.
> 
> Thanks for your reply. Alas, each of dozens of users would need to have 
> their own instance of the document (possibly multiple) to modify 
> contents and have them recalculated by LibreOffice.
> I will check the documentation if the once loaded document can be 
> duplicated and measure how long it will take in a single-user situation.

I have not found a method to conveniently duplicate or clone a document 
when skimming 
https://wiki.documentfoundation.org/Documentation/DevGuide/Office_Development#Handling_Documents 
or when inspecting the document object in Python.

So, i have implementeded a cloning mechanism around
`desktop.loadComponentFromURL('private:factory/scalc', '_blank', 0, ())`
which copies all sheets and from each sheet it copies the data arrays of 
used cell ranges (hope this description is not condensed too much). It 
still needs handling of named ranges and maybe other things.

This is much quicker than (re)loading the file, currently needing only 
5s instead of 25s. Alas, it is still too slow to be run on a web request 
basis.

Does anybody know of a faster way how to duplicate a complete document 
in memory? I can post my testing code if you like (not the document, tho).

Cheers,
   Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20250311/8016dfe4/attachment.sig>


More information about the LibreOffice mailing list