A bold white title of 'Convert Excel Spreadsheets' sits next to an XLS document icon then an arrow pointing to the right where there is a CSV document icon all against a black background with a dark blue grid.

Convert Excel Spreadsheet File Format (XLS, XLSX) to CSV

If one works with spreadsheets eventually there will come a time when the information needs to be processed and converted to the plain text data format called Comma Separated Values (CSV). One off situations can typically be resolved by manually saving the document to CSV using the spreadsheet productivity software suite program of choice (e.g. LibreOffice Calc). Yet when it comes to repeatedly doing this it is more effective to use the command line to quickly convert the necessary spreadsheet documents. There are several Free and Open Source Software (FOSS) options available, but there are a few things to consider before one ventures into the conversion process.

Difference Between File Formats

Excel spreadsheet documents are commonly saved with the file extension of “XLSX” or “XLS” and are binary or Extensible Markup Language (XML) based. Each file stores a variety of data such as structured tables, formulas, pivot tables, charts, cell formatting, embedded objects, etc. This is all on top of being able to also store multiple sheets in the workbook.

When it comes to the file format Comma Separated Values (CSV) they are saved with the file extension of “csv”. All data is stored in plain text and each value is delimited by a comma to separate values. Each line represents a row and each comma divides the data into columns. Since this format is simplistic it does not support formulas, functions, style formatting, macros or even multiple sheets. The file format is designed to store raw data that is easy to read and process no matter the device or system used. This is important to be aware of these limitations in cases where certain data must be retained in the conversion process.

Environment

Testing was affirmed using the following.

  • Arch Linux
  • Debian 13
  • LibreOffice v25.2.3.2, v26.2.4.2
  • Gnumeric v1.12.57
  • Catdoc v0.95
  • csvkit v2.2.0

Assumptions

  • Document being converted only contains one workbook
  • Document being converted has a character encoding of UTF-8
  • General understanding of using a GNU/Linux or Unix terminal (command-line interface)
  • Steps prefixed with a “$” (dollar sign) represents the CLI (command-line interface) prompt
  • Steps prefixed with a “#” (number sign) represents the CLI prompt with elevated user permissions (e.g. root)
  • The text after the “$” or “#” is to be entered at the CLI

LibreOffice

An office productivity software suite developed by The Documentation Foundation that includes applications for word processing (Writer), spreadsheets (Calc), presentations (Impress), vector graphics editor (Draw), database management (Base), and formula editing (Math). LibreOffice is available on the majority of operating systems such as GNU/Linux, macOS, Microsoft Windows, and Unix.

LibreOffice Calc supports converting Microsoft Excel spreadsheet, XLS (1997-2007) and XLSX (2010-365) into Comma Separated Values (CSV) through the Graphical User Interface (GUI) and Command Line Interface (CLI). Here are the necessary steps to use either option.

Graphical User Interface

  1. Open LibreOffice Calc application.
  2. Open the desired Excel spreadsheet document.
  3. Save spreadsheet to CSV.

    Click on “Save As…” and towards the bottom right of the dialog select “Text CSV (.csv)”. Enter the desired file name and click the “Save” button.

Command Line

Using the terminal or console enter the following command example to convert an existing Excel spreadsheet to CSV. Adjust existing filename “input.xlsx” and output directory as necessary. Upon successful conversion there will not be any output.

$ libreoffice --headless --convert-to csv "input.xlsx" --outdir ./
--headless    Use the application in "headless mode" without the Graphical User Interface (GUI).
--convert-to  Batch convert file(s) to a specified file format.
--outdir      The directory of where the converted file(s) will be saved. If not specified then current working directory is used.

To install LibreOffice Calc here are a few installation command examples to be used in the terminal for the applicable operating system.

Arch Linux

# pacman -Sy libreoffice-still

Debian / Ubuntu

# apt-get install libreoffice

Fedora

# dnf install libreoffice

Gnumeric

A standalone spreadsheet program which is a part of the GNOME Project, the community behind the GNOME desktop environment and the software platform upon which it is based.

Gnumeric supports converting Microsoft Excel spreadsheet, XLS (1997-2007) and XLSX (2010-365) into Comma Separated Values (CSV) through the Graphical User Interface (GUI) and Command Line Interface (CLI). Here are the necessary steps to use either option.

Graphical User Interface

  1. Open Gnumeric application.
  2. Open the desired Excel spreadsheet document.
  3. Export spreadsheet to CSV.

    Click on the menu “Data” > “Export Data” > “Export as CSV File…”.

  4. Save spreadsheet to CSV.

    Set the desired filename, save location and the click on the “Save” button.

Command Line

With the use of spreadsheet format converter program provided by Gnumeric an Excel spreadsheet can be converted to Comma Separated Values (CSV). Here is a command example that is used within the terminal or console. Make sure to adjust the existing document name (input.xlsx) and output filename (output.csv) as desired.

$ ssconvert input.xlsx output.csv

Gnumeric can be installed through graphical application like GNOME Software or KDE Discover. Follow the below command examples on how to install Gnumeric using the terminal for the applicable operating system.

Arch Linux

# pacman -Sy gnumeric

Debian / Ubuntu

# apt-get install gnumeric

Fedora

# dnf install gnumeric

CSV2Kit

A command line suite of tools to convert to and working with files formatted in Comma Separated Values (CSV).

Using the program in2csv will convert Microsoft Excel spreadsheet, XLS (1997-2007) and XLSX (2010-365) into Comma Separated Values (CSV). Below illustrates how simple it is to convert a spreadsheet to CSV on the command line. Remember to change the existing spreadsheet filename (input.xlsx) and the output filename (output.csv) as desired.

$ in2csv input.xlsx > output.csv

I’ve provided a few command examples below to install csvkit along with in2csv using the terminal for the applicable operating system.

Arch Linux

# pacman -Sy csvkit

Debian / Ubuntu

# apt-get install csvkit

Catdoc XLS2CSV

Easily convert Microsoft Excel spreadsheet documents (XLS, 1997-2007) into Comma Separated Values (CSV) file format using xls2csv command line program. Newer Excel documents are not supported (XLSX, 2010-365).

The below command example illustrates how an XLS file is converted to CSV.

$ xls2csv input.xls > output.csv

To install catdoc along with xls2csv here are a few installation command examples using the terminal for the applicable operating system.

Arch Linux

# pacman -Sy catdoc

Debian / Ubuntu

# apt-get install catdoc

Fedora

# dnf install catdoc

PowerShell

If Microsoft Excel is installed on Windows the following script can be used. The script will automate opening Excel in the background, export the associated sheet of the workbook as CSV and then saves it to the defined directory. Though this option is not entirely Free and Open Source Software, it is still a viable solution for those that may not have any other choice.

  1. Click on the Windows Start Menu or press the Windows key.
  2. Type without double quotes “powershell”.
  3. Click on “Open” or press Enter key.
  4. Copy and paste each line into the PowerShell prompt.

    Make sure to adjust paths. If there are multiple sheets manually increment the number found in parentheses, $Worksheet = $Workbook.Sheets.Item(1).

     $Excel = New-Object -ComObject Excel.Application
     $Workbook = $Excel.Workbooks.Open("C:\Users\Adam\Documents\example.xlsx")
     $Worksheet = $Workbook.Sheets.Item(1)
     $Worksheet.SaveAs("C:\Users\Adam\Documents\example.csv", 6)
     $Workbook.Close()
     $Excel.Quit()
    

If there are issues regarding character encoding the following PowerShell script can be used to convert the characters to UTF-8.

Get-Content "C:\path\to\file.csv" -Raw | Out-File -FilePath "C:\path\to\file_utf8.csv" -Encoding utf8
Support Adamsdesk

Direct support from our audience allows for us to achieve our goal of sustainability. Cast Your Vote of Support.

Donate Affiliates
References