How to validate an Excel XLSX Spreadsheet in Salesforce Apex

In this tutorial, we are going to show you just how easy it is to perform validation upon Excel files using Apex.

First, download our Apex API Client and unzip it. Then copy the contents into your project folder.

Then call validateDocumentXlsxValidation, with your XLSX as the inputFile:

SwagValidateDocumentApi api = new SwagValidateDocumentApi();SwagClient client = api.getClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');Apikey.setApiKey('YOUR API KEY');Map<String, Object> params = new Map<String, Object>{'inputFile' => Blob.valueOf('Sample text file\nContents')};try {// cross your fingersSwagDocumentValidationResult result = api.validateDocumentXlsxValidation(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}

And now the API will respond to us in this format here:

"DocumentIsValid": true,
"ErrorCount": 0,
"WarningCount": 0,
"ErrorsAndWarnings": [
"Description": "string",
"Path": "string",
"Uri": "string",
"IsError": true


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