Shell – Convert xlsx to xls in linux shell script

excelshell-script

I need to convert ".xlsx" file to ".xls" using shell command.

At my work we are currently using xlsx2csv command but now requirement has been changed and we need to convert all ".xlsx" files to ".xls" files for further calculation.

For that, Some guy at my work has developed one command that can convert ".xlsx" to ".xls" but, that is applicable for only one sheet..

We have multiple sheets in one file.

Thanks in advance….

Best Answer

If you install LibreOffice, you can use the following command:

libreoffice --headless --convert-to xls myfile.xlsx

or just:

libreoffice --convert-to xls myfile.xlsx

in recent version (>= 4.5) where --convert-to implies --headless.

This will create myfile.xls, and keep the original myfile.xlsx—so you’ll probably need to do a cleanup after you've validated the conversion is successful.

Related Question