I am looking for a Java library (preferably in Maven Central) that can read XLS and XLSX and save the sheet to CSV.

I am looking for something higher level than poi and jxl as neither of these have direct export to CSV without writing lots of code.

I am also aware of the poi xls2csv sample but I am looking for a reusable library and not a class to paste in my project.

  • Please give some feedback.
    – hc_dev
    Feb 19, 2019 at 6:30
  • There will always be some customization, configuration or writing code. Since CSV is used with different delimiters, quotes, charsets, formats for number/date/time. Thus popular available libraries won't have that one-size-fits-all method called DirectExporter.fromXlsToCsv( xlsFile, csvFile ).
    – hc_dev
    Feb 21, 2019 at 11:14
  • Can you reveal some context for your need. Why you don't want to write code? For which (recurring) tasks will it be used? How should your desired higher level look like (maybe in pseudo-code)? What is the environment you want to integrate the library?
    – hc_dev
    Feb 21, 2019 at 11:18
  • Bear in mind that this is a 2.5 year old question. Excel can open a file and can also export to CSV with sensible-ish defaults. So DirectExporter.fromXlsToCsv( xlsFile, csvFile ) is what I was looking for back then. I believe I had a generic CSV comparison library and exporting XLS(X) to CSV would have made it a (reasonably) useful generic XLS(X) comparison. Since it was supposed to be generic, having POJOs for each file is not feasible.
    – opticyclic
    Feb 26, 2019 at 15:32

2 Answers 2


Spire.XLS for Java library is capable of reading XLS/XLSX files and saving them as CSV. You just need to write 4 lines of code.

Maven dependencies:


Save a worksheet of an XLS/XLSX file as CSV:

import com.spire.xls.*;
import java.nio.charset.Charset;

public class ExcelToCSV {
    public static void main(String[] args) {
        //Create a workbook
        Workbook workbook = new Workbook();    
        //Load an xlsx or xls file
        //Get the first sheet
        Worksheet sheet = workbook.getWorksheets().get(0);    
        //Save the sheet as CSV
        sheet.saveToFile("output/ToCSV_out.csv", ",", Charset.forName("UTF-8"));

For more information, you can read the documentation here: Java: Convert Excel to CSV and Vice Versa

  • It looks useful and what I was looking for at the time of the question. It should be pointed out for future readers that it is a 30-day trial and not an open-source library.
    – opticyclic
    Apr 7, 2022 at 0:05

Searching GitHub I found Coreoz/Windmill:

Windmill is a library to parse or write Excel and CSV files through a fluent API that takes advantage of Java 8 Stream and Lambda features.

Windmill targets the writing/parsing of List/Collection data. It will especially stand out for use cases like exporting/importing a result set from/to a database.

It is based on the projects Apache POI and OpenCSV to manipulate Excel and CSV files.

Plus it's available in Maven Central:

  • This is a slight improvement over just using POI and OpenCSV directly. It appears that it still requires a fair amount of code to be written though. However, now that code is inline in the fluent API.
    – opticyclic
    Feb 20, 2019 at 20:41
  • In my experience with XLS(X)-to-CSV it seems currently the best free java-lib for your requirements. The 5-10 lines of code are needed to integrate the lib in your code-base as well as configurate your custom conversion-mapping (CSV-delimiters, formatting, and so on).
    – hc_dev
    Feb 21, 2019 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.