How to Validate an Excel Document using Java

Data validation serves an important role during the accumulation of objects for storage. It helps us ensure that invalid documents don’t accidentally make it to our database as corrupt files that can’t be opened, and it can create a layer of security by the same token, ensuring various scripts, macros and executables don’t sneak by as invalid files.

Our Excel Validation API will specifically check that all XLSX files are valid, and it will provide useful information about any invalid files including an error count, warning count, and a description of both. Further, it will let you know if the document was password protected, which is always cause for concern. Below, I’ll demonstrate how you can easily structure an API call in Java to take advantage of this validation service.

Let’s begin by installing the SDK with Maven. First, include a reference in the pom.xml repository:

Next, include a reference in the pom.xml dependency:

Finally, include the following imports at the top of your file, then call the validation function:

You’ll only need to satisfy two parameters here, which include your input file for the operation, and your Cloudmersive API key. You can get a key by registering a free account on our website, which will provide you with a limit of 800 API calls per month.



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

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