How to get columns from an Excel XLSX spreadsheet in Java

Manipulation of XLSX spreadsheets is remarkably quite difficult when approached programmatically. This format is like an onion, requiring the peeling of multiple layers before the relevant data can be retrieved. The process is just as much fun as it sounds, and quite time consuming. To avoid this productivity quagmire, this tutorial will present a nice and easy solution that will take a small fraction of the time.

For Java users, we will need to add a reference to Jitpack to our repositories.


And then we drop in a reference for our API client among the dependencies.


Lastly, our function invokation:

// 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.EditDocumentApi;ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: ApikeyApiKeyAuth 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");EditDocumentApi apiInstance = new EditDocumentApi();GetXlsxColumnsRequest input = new GetXlsxColumnsRequest(); // GetXlsxColumnsRequest | Document input requesttry {GetXlsxColumnsResponse result = apiInstance.editDocumentXlsxGetColumns(input);System.out.println(result);} catch (ApiException e) {System.err.println("Exception when calling EditDocumentApi#editDocumentXlsxGetColumns");e.printStackTrace();}

Done! Now, wasn’t that easy?

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