Linux Convert xlsx to csv

Files with the .xlsx extension are Microsoft Excel spreadsheets. These files can be converted to .csv (comma separated values) files to be more compatible with other applications, or to be opened by a plain text editor.

In this tutorial, you will see different methods to convert xlsx files to csv in terminal and GUI on Linux.

Convert xlsx to csv – Command Line

We will look at using several different command line tools to convert the files. All will work with major Linux distros, so take your pick on which one you’d like to use.

Using Gnumeric

Gnumeric is a very useful and light software that can be used to export and import files in different file formats.

Install Gnumeric using the appropriate command:

$ sudo apt install gnumeric # Ubuntu and Debian-based
$ sudo dnf install gnumeric # Fedora and RHEL-based
$ sudo pacman -S gnumeric # Arch Linux and Manjaro
$ sudo zypper install gnumeric # OpenSUSE

Example 1. To convert an xlsx file – that contains only one workbook, to csv format using Gnumeric, execute the following command:

$ ssconvert file.xlsx file.csv

Example 2. If your xlsx spreadsheet contains two or more workbooks, simply pass the -S option:

$ ssconvert -S file.xlsx file.csv

To check the new csv file, use the cat command:

$ cat file.csv

Converting xlsx file to csv format using gnumeric

Using CSVkit

csvkit is a command tool developed in Python. It can be used to convert xlsx to csv and provides other functions for working with csv files.

Install CSVkit using the appropriate command:

$ sudo apt install csvkit # Ubuntu and Debian-based
$ sudo dnf install pip && pip install csvkit # Fedora and RHEL-based
$ sudo pacman -S csvkit # Arch Linux and Manjaro
$ sudo zypper install python3-pip && pip install csvkit # OpenSUSE

To convert xlsx files to csv, use the in2csv command:

$ in2csv file.xlsx > file.csv

Converting xlsx file to csv format using csvkit

Using xlsx2csv

xlsx2csv is another Python-based tool, whose primary function is to convert xlsx files to csv.

Install xlsx2csv using the appropriate command:

$ sudo apt install xlsx2csv # Ubuntu and Debian-based
$ sudo dnf install pip && pip install xlsx2csv # Fedora and RHEL-based
$ yay -S python-xlsx2csv # Arch Linux and Manjaro (from AUR)
$ sudo zypper install python3-pip && pip install xlsx2csv # OpenSUSE

To convert xlsx files to csv using xlsx2csv, execute:

$ xlsx2csv file.xlsx > file.csv

Converting xlsx file to csv format using xlsx2csv

Using LibreOffice

LibreOffice can open and edit both xlsx and csv files. From the command line, it can also convert the files:

$ libreoffice --headless --convert-to csv file.xlsx

Converting xlsx file to csv format using LibreOffice headless tool

Convert xlsx to csv – GUI Method

You can install LibreOffice to manage your xlsx and csv files, and use LibreOffice Calc to convert between the two types.

Install LibreOffice using the appropriate command:

$ sudo apt install libreoffice # Ubuntu and Debian-based
$ sudo dnf install libreoffice # Fedora and RHEL-based
$ sudo pacman -S libreoffice # Arch Linux and Manjaro
$ sudo zypper install libreoffice # OpenSUSE

Step 1. Open LibreOffice Calc from your system’s menus.

Opening LibreOffice Calc from menu

Step 2. Open your xlsx file, then go to the ‘File’ menu.

Accessing file menu through LibreOffice Calc

Step 3. Next, click on ‘Save As’.

Saving a xlsx file on LibreOffice Calc

Step 4. Open the format option as shown in the image below.

Opening the format list on LibreOffice Calc

Step 5. Select ‘Text CSV’ format from the drop down menu.

Selecting csv format in LibreOffice Calc

Step 6. Finally, provide the new name for the csv file and then click on ‘Save’.

Saving a xlsx file to csv format file on LibreOffice Calc

Leave a Comment

Your email address will not be published. Required fields are marked *