Convert xlsx to xls in linux shell script

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.


you can also try ssconvert the companion converter tool of gnumeric

ssconvert in.xlsx out.xls

(as usually, see man ssconvert)

For normal cases, this is fine. If the input file is very advanced in both (libreoffice and gnumeric)-based converters, some details may be lost.