How to validate an Excel XLSX Spreadsheet in Python

Cloudmersive
1 min readAug 20, 2019

--

Today let’s apply one of our APIs to make validating Excel spreadsheets trivial, the way it should be. First we install our document client using pip install:

pip install git+https://github.com/Cloudmersive/Cloudmersive.APIClient.Python.Convert.git

Now simply call validate_document_xlsx_validation using the desired XLSX file:

from __future__ import print_function
import time
import cloudmersive_convert_api_client
from cloudmersive_convert_api_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_convert_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Apikey'] = 'Bearer'
# create an instance of the API class
api_instance = cloudmersive_convert_api_client.ValidateDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))
input_file = '/path/to/file' # file | Input file to perform the operation on.
try:
# Validate a Excel document (XLSX)
api_response = api_instance.validate_document_xlsx_validation(input_file)
pprint(api_response)
except ApiException as e:
print("Exception when calling ValidateDocumentApi->validate_document_xlsx_validation: %s\n" % e)

And we will be given the validity of the document as well as possible errors and warnings for said document.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet