How to Convert an Excel XLS (97–03) Spreadsheet to Excel XLSX using Java

Cloudmersive
2 min readOct 13, 2022

--

When you’re using historical data, old-school data formats are just part of the day-to-day grind. Running into Excel XLS spreadsheets from 1997–2003 Windows format means you need to make a hasty conversion to a modern format, or you’ll find yourself completely forgoing compatibility with dozens of modern applications. Thankfully, you can easily transition your old XLS spreadsheets to modern XLSX format with a simple & free API service. Our XLS (97–03) to XLSX API requires only your input file path & Cloudmersive API key (you can get one by registering a free account on our website) as parameters and will return the encoding for a brand new XLSX file. Below, I’ll demonstrate how to utilize this API by structuring your API call with ready-to-run Java code examples.

Let’s start by installing the Cloudmersive Document Conversion API client. First add a reference to the repository in pom.xml:

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

And then add a reference to the dependency in pom.xml:

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v4.25</version>
</dependency>
</dependencies>

With installation complete, we can now include the imports at the top of our file & call the function. Include your API key in the field shown by the code comments, and then copy your input file path in the inputFile field:

// 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)
//Apikey.setApiKeyPrefix("Token");
ConvertDocumentApi apiInstance = new ConvertDocumentApi();
File inputFile = new File("/path/to/inputfile"); // File | Input file to perform the operation on.
try {
byte[] result = apiInstance.convertDocumentXlsToXlsx(inputFile);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ConvertDocumentApi#convertDocumentXlsToXlsx");
e.printStackTrace();
}

And with that, you’re all done — no more code required. Nice and easy!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet