Sick of having a bunch of old outdated XLS spreadsheets gathering dust? Converting these into PDFs might be a bit more useful, but how difficult might this be to get set up? Well, it’s actually very easy if you have the right API for the job, which is what we are going to be looking into today.
To get us started, we shall install our client using pip install.
pip install cloudmersive-convert-api-client
And to follow this, we call convert_document_xls_to_pdf, which you can see set up in this example I have for you below:
from __future__ import print_functionimport timeimport cloudmersive_convert_api_clientfrom cloudmersive_convert_api_client.rest import ApiExceptionfrom pprint import pprint# Configure API key authorization: Apikeyconfiguration = 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 classapi_instance = cloudmersive_convert_api_client.ConvertDocumentApi(cloudmersive_convert_api_client.ApiClient(configuration))input_file = '/path/to/file' # file | Input file to perform the operation on.try:# Convert Excel XLS (97-03) Spreadsheet to PDFapi_response = api_instance.convert_document_xls_to_pdf(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_xls_to_pdf: %s\n" % e)
Alright, we are finished already. It’s time to go pop the champagne, because you just saved yourself hours of coding and headache!