How to create a blank Excel XLSX spreadsheet in Java

Cloudmersive
1 min readFeb 12, 2020

--

The goal of today’s tutorial is to set up blank XLSX creation using Java. Not to worry, this is going to be very fast with the help of one of our APIs. Let’s get right to it.

First order of business, we need to compile our library. This will require a pair of references to be place in your Maven POM file.

Reference for repositories.

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

Reference for dependencies.

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v3.34</version>
</dependency>
</dependencies>

Let’s proceed with an invocation of editDocumentXlsxCreateBlankSpreadsheet:

// 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();CreateBlankSpreadsheetRequest input = new CreateBlankSpreadsheetRequest(); // CreateBlankSpreadsheetRequest | Document input requesttry {CreateBlankSpreadsheetResponse result = apiInstance.editDocumentXlsxCreateBlankSpreadsheet(input);System.out.println(result);} catch (ApiException e) {System.err.println("Exception when calling EditDocumentApi#editDocumentXlsxCreateBlankSpreadsheet");e.printStackTrace();}

And, we’re done! Our blank XLSX file is ready to go! Now we can proceed to populate it with text, tables, and images using some of our other functions.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet