Running Libre office as a service is an extremely powerful way to run a system.
The (Universal Network Objects) UNO / Basic project is the back bone to this power.
The unoconv answer is solid and valid, however I guessed you might want to run a libre as a service.
You asked a couple of questions.
- How to debug a macro in Libre or Open Office
And
- Can you run a macro and save a file as xls (using Filter Options MS Excel 97 / xls format) ?
Here's the command
soffice --headless "macro:///Library1.Module4.OdsToXls(~/Desktop/Test/test1.ods)"
First of all I ran the macro from inside libre then I added the parameter to the procedure.
You could use MsgBox to debug
I've left the debug info in for you to look at.
sub OdsToXls(AbsoluteFileName as String)
REM IN SpreadSheetPath is the FULL PATH and file
REM AbsoluteFileName="/home/<user>/Desktop/Test/test1.ods"
REM AbsoluteFileName="~/Desktop/Test/test1.ods"
REM SaveAsFile
rem ----------------------------------------------------------------------
rem define variables
Dim Doc As Object
Dim Dummy()
dim dispatcher as object
dim PartURL as string
dim args1(1) as new com.sun.star.beans.PropertyValue
dim BaseFilename as string
rem used for testing
rem AbsoluteFileName="~/Desktop/Test/test1.ods"
PartURL="file:///"
rem ----------------------------------------------------------------------
rem get access to the document
If (Not GlobalScope.BasicLibraries.isLibraryLoaded("Tools")) Then
GlobalScope.BasicLibraries.LoadLibrary("Tools")
End If
rem content of an opened window can be replaced with the help of the frame parameter and SearchFlags:
SearchFlags = com.sun.star.frame.FrameSearchFlag.CREATE + com.sun.star.frame.FrameSearchFlag.ALL
Url=ConvertToUrl(PartURL+AbsoluteFileName)
rem MsgBox(Url)
Doc = StarDesktop.loadComponentFromURL(Url, "MyFrame", _SearchFlags, Dummy)
BaseFilename = Tools.Strings.GetFileNameWithoutExtension(Url)
rem msgBox(BaseFilename)
rem ----------------------------------------------------------------------
args1(0).Name = "URL"
args1(0).Value = BaseFilename+"."+"xls"
args1(1).Name = "FilterName"
args1(1).Value = "MS Excel 97"
Doc.StoreAsURL( args1(0).Value , args1())
Doc.close(true)
end sub
You could add to this by using a while loop on a directory and having an output directory.
If you're interested in scanning a directory and picking up all the files and processing them, then this may help you Stackoverflow Question: Saving specific Excel sheet as .csv
If you have any questions please feel free to ask.
Ref Filter_Options
All the best