How to convert Excel XLSX to CSV Files in Java

File format conversion, while useful, is a pretty dry topic under the best of circumstances. With that in mind, today’s tutorial is designed to get this thorn out of your side as quickly as possible so that you can move on to something more important. Let’s get straight to it.

First off, we need to use Jitpack to compile our library. So we will need to set up some references in the Maven POM file.

Repository reference:


Dependency reference:


With that done, we simply need to call convertDocumentXlsxToCsv and let the API do the work for us:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.ConvertDocumentApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
ConvertDocumentApi apiInstance = new ConvertDocumentApi();
File inputFile = new File("/path/to/file"); // File | Input file to perform the operation on.
String outputEncoding = "outputEncoding_example"; // String | Optional, set the output text encoding for the result; possible values are UTF-8 and UTF-32. Default is UTF-32.
try {
byte[] result = apiInstance.convertDocumentXlsxToCsv(inputFile, outputEncoding);
} catch (ApiException e) {
System.err.println("Exception when calling ConvertDocumentApi#convertDocumentXlsxToCsv");

All done! Simple, right?

Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store