Reputation: 11
I am new in Python and Basic. I am trying to replicate the IMPORTHTML function from Google Sheets in LibreOffice (LO) Calc. In a nutshell, I want to create a GetHtmTable( Url, Table Index) Basic function in Calc which will call a Python script to do the heavy work.
So based on Villeroy's great example, I implemented in LO 5.1.6.2. the Basic SOUNDEX function which calls the Python script sheetFunctions.py
to get familiar with the process. My environment is Linux Mint 18, I use Python 3, I imported all kind of libraries such as Uno, PIP etc.. I use PycharmProjects
as a Python editor.
I see clearly under the LO Calc menu tools->macro->organize macros->python the sheetFunctions.py
Python script, which indeed is in the folder /usr/lib/libreoffice/share/Scripts/python
.
Whenever, I run the SOUNDEX Basic function I see the following error message:
BASIC runtime error. An exception occurred Type: com.sun.star.script.provider.ScriptFrameworkErrorException Message: : an error occurred during file opening
/usr/lib/libreoffice/program/pythonscript.py:429 in function getModuleByUrl() [lastRead = self.sfa.getDateTimeModified( url )]
/usr/lib/libreoffice/program/pythonscript.py:993 in function getScript() [mod = self.provCtx.getModuleByUrl( fileUri )]
I tried to debug the SOUNDEX basic function and found out the blocking point is when the program runs getScript("vnd.sun.star.script:sheetFunctions.py$soundex?language=Python&location=user")
.
I've been trying for days now to overcome this error, unsuccessfully I must confess.
I wonder if I need to bring some extra extensions in the Basic environment or a missing add-in in the Linux/Python one?
I changed the location=user by location=document and got stuck again. I added recently libreoffice-script-provider-python thanks to the command sudo apt-get install libreoffice-script-provider-python
but this did not help. I also embedded in the Calc document the Python script but same this did not solve the issue.
Upvotes: 1
Views: 1330
Reputation: 13790
The location name does not match. The standard place for self-written scripts is under the user directory. This is location=user
, for example ~/.config/libreoffice/4/user/Scripts/python
.
Then there is location=share
, which refers to the path in your question. These parameters are described under Python Script in the URI Specification.
See also my answer to this question. Be sure to try the APSO extension if you haven't yet. Especially, APSO helps when using location=document
, because embedding requires several steps including editing manifest.xml.
Upvotes: 2