Home » excel » Convert from Excel xlsx to xls in Java

Convert from Excel xlsx to xls in Java

Posted by: admin April 23, 2020 Leave a comment


I have an Excel 2007 xlsx file that I would like to programmatically convert to an .xls file. The xlsx file is an export from a reporting tool, and I would like to convert it to xls for better compatibility with the software stack of my application users. The xlsx is as plain as it gets. Just rows with data and basic type information (int/date/string). No formulas.

My platform is Java, and I do not have Microsoft Office installed. I’m looking for a solution that will allow me to convert between the formats with the least amount of effort. I.e. I’d like to avoid having to write a custom “copy application” that would read the xlsx file and copy the rows and formatting to another file. Preferably, the solution is open source and/or free.

I have looked at POI, and as far as I could tell, it can read and write both xls and xlsx files. But I was not able to tell by browsing the documentation and examples if it could read one format and write out in the other. Before I dig in any deeper, I would like to check if any of you out there have done anything like this before in Java, and if you have any tips.

How to&Answers:

Converting with POI would be a tedious task. I would like to point you to JODConverter. JODConverter is used by OpenOffice to convert its stuff, so it should work fine for that task.

However, that being said, I have not used JODConverter myself.