Files with the
xlsx extension have been formatted for Microsoft Excel. These documents contain columns and rows of data, just like those found in Google Sheets or LibreOffice Calc. This data can be stored as CSV (comma separated values), making it easily readable by various applications or even plain text editors. Due to their proprietary nature, Excel spreadsheets can be difficult to open on Linux systems, making CSV files a much more cross compatible format.
In this guide, we’ll show you a few different methods to convert Excel spreadsheets into comma separated files. This can be done from the command line, or you can open the spreadsheets with LibreOffice and resave them in the desired format, as you’ll see below.
In this tutorial you will learn:
- How to convert xlsx files to csv via command line with ssconvert
- How to convert xlsx files to csv via command line or GUI with LibreOffice
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Convert xlsx files to csv via command line
One of the best command line tools for converting xlsx files would be the gnumeric software package. You can use the appropriate command below to install it with your system’s package manager on any Linux distro.
To install gnumeric on Ubuntu, Debian, and Linux Mint:
$ sudo apt install gnumeric
To install gnumeric on CentOS, Fedora, AlmaLinux, and Red Hat:
$ sudo dnf install gnumeric
To install gnumeric on Arch Linux and Manjaro:
$ sudo pacman -S gnumeric
After gnumeric is installed, you’ll have access to the
ssconvert command on your system. Use the following command syntax to convert an Excel spreadsheet in terminal.
$ ssconvert distros.xlsx distros.csv
You can now open the CSV formatted file in a plethora of editing applications, or simply view it with the
cat command or any plain text editor.
If the spreadsheet you’re working with contains multiple tabs (or “workbooks” as they’re called in Excel), you’ll need to add the
-S option to your
$ ssconvert -S distros.xlsx distros.csv
Note that this will generate multiple files, with each CSV file being a different tab from the original Excel spreadsheet.
$ ls | grep distros.csv distros.csv.0 distros.csv.1 distros.csv.2 distros.csv.3
If for some reason you wish to use any other delimiter instead of a comma, use the
-O option to accomplish this task. In the next example we will convert the Excel file to a semi-column separated file:
$ ssconvert -S -O 'separator=;' distros.xlsx distros.txt
ssconvert command will try to guess output file format based on the file extension supplied as an argument. Make sure not to use
csv extension for your output file when using
-O option. Otherwise you will get the following error message:
The file saver does not take options
Convert xlsx files to csv via GUI
LibreOffice Calc is a spreadsheet editing application very similar to Microsoft Excel. It can even open Excel formatted files that have the
xlsx file extension, or convert these files to CSV from the command line.
The LibreOffice suite often comes installed by default on many Linux distros, so there’s a chance your system already has it. If not, you can use the appropriate command below to install it with your system’s package manager.
To install LibreOffice on Ubuntu, Debian, and Linux Mint:
$ sudo apt install libreoffice
To install LibreOffice on CentOS, Fedora, AlmaLinux, and Red Hat:
$ sudo dnf install libreoffice
To install LibreOffice on Arch Linux and Manjaro:
$ sudo pacman -S libreoffice
After LibreOffice is installed, search for it in your GUI’s application launcher to open the LibreOffice Calc program.
To open your xlsx file in the program, click on File > Open and locate the file on your hard drive. As you can see below, we have successfully opened our Excel formatted spreadsheet in LibreOffice Calc.
To convert the file to CSV or a variety of other formats, click on File > Save As. Then, choose a format to save the file in. Among the list of options, you will see CSV listed.
Alternatively, you can convert an xlsx file to CSV format by using LibreOffice on the command line. The following command syntax should do the job.
$ libreoffice --headless --convert-to csv distros.xlsx
In this guide, we saw several methods to convert an Excel formatted xlsx spreadsheet to a comma separated CSV file on Linux. Although xlsx files are made with a Microsoft application, Linux programs such as LibreOffice Calc are still capable of opening the files and editing them. LibreOffice can also resave the file as CSV or a variety of other formats. For batch converting, you will find that the command line methods covered here are much more convenient.