The xlsx file name extension is a new file format based on XML, used by Microsoft Office Excel 2007 spreadsheet application. The letter "x" appended to the existing "xls" extension used by earlier versions of Excel, signifies that the format is based on XML. If you would like to open or edit an xlsx file created by Excel 2007, on an earlier version of Excel or any other spreadsheet application, you need to convert xlsx files first.
There are four different ways you can convert xlsx files on Linux. The first method is to use Gnumeric. Gnumeric is a free spreadsheet program which can import or export data in different file formats such as CSV, .xls and .xlsx. Gnumeric comes with a command-line utility called ssconvert which can convert between different spreadsheet file formats. In order to convert xls files to xls or csv format by using Gnumeric, first install Gnumeric. Once Gnumeric is installed, you can use ssconvert.
Note that ssconvert accepts arguments in the following format.
In the above, "--export-type" is optional, and without "--export-type", ssconvert can infer export type from the extension of output file. If you want to explicitly specify export type, ID can be one of the following.
- "Gnumeric_Excel:excel_dsf" : Microsoft Excel 97/2000/XP, 5.0/95 format
- "Gnumeric_Excel:xlsx" : Microsoft Excel 2007
- "Gnumeric_pdf:pdf_assistant" : Portable Document Format (PDF)
- "Gnumeric_stf:stf_csv" : Comma Separated Values (CSV)
So if you would like to convert xlsx files to csv format using ssconvert:
$ ssconvert --export-type=Gnumeric_stf:stf_csv input.xls output.txt
The drawback of the above method of converting xlsx files using Gnumeric is that you need to install Gnumeric which may be too bloated software to install just for file conversion. A more lightweight way is to use xlsx2csv which is a python tool for xlsx to csv conversion.
$ cd xlsx2csv
$ ./xlsx2csv.py input.xlsx output.csv
Besides Gnumeric and xlsx2csv, you can also use OpenOffice to perform xlsx format conversions. OpenOffice comes with a command-line utility called unoconv which can convert .xlsx files.
$ unoconv -f csv input.xlsx
Note that once you install unoconv using apt-get, it will install OpenOffice package as well.
The final method of converting xlsx files is to use Google Spreadsheets. Google Spreadsheets can import Excel 2007 files. Thus, all you have to do is to import your .xlsx file on to Google Docs Spreadsheet, click "Download as" menu, and choose an appropriate file format: Excel (.xls), PDF, CSV, Text. Note that document files which can be uploaded to Google Docs for conversion cannot be larger than 2MB.
Subscribe to Xmodulo
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.