I'm working with an ODS file in LibreOffice, and every now and then I want to convert it to CSV from the command line.
I have found two tools for this: libreoffice --headless --convert-to csv
and unoconv -f csv
but none of them works when there is an UI instance of LibreOffice running.
Is there a way to convert an ODS file to CSV from the command line, while LibreOffice UI instance is running?
To convert csv on the command line while LibreOffice is running, just skip the --headless
parameter. The following command (run in PowerShell) worked for me even while C:\TEMP\Untitled1.ods
resp. /tmp/Untitled1.ods
was opened in LibreOffice Calc:
& 'C:\Program Files\LibreOffice\program\soffice.exe' --convert-to csv --outdir C:\TEMP\ .\Untitled1.ods
Or similar, if the present working directory is C:\Program Files\LibreOffice\program\
:
.\soffice --convert-to csv --outdir C:\TEMP\ C:\TEMP\Untitled1.ods
soffice --convert-to csv --outdir /tmp/ /tmp/Untitled1.ods
On linux, you could alternatively use the libreoffice
command instead of soffice
(seems to be linux-specific...):
libreoffice --convert-to csv --outdir /tmp/ /tmp/Untitled1.ods
In all cases, Untitled.csv
was created in the expected place.