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 '19 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 '19 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 '19 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 '19 at 15:32

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 '19 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 '19 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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