How to Convert ODS to PNG in Python

Converting spreadsheets into images is no one’s idea of a fun afternoon. What say you to avoiding that whole mess, yet still getting good results? Don’t worry, I’m not pulling your chain. We can get this done super quickly and easily through use of an API. I’m going to show you how to get it set up.

First, we need to install the client:

pip install cloudmersive-convert-api-client

Now we can call convert_document_ods_to_png, which is detailed in this example code here:

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 ODS Spreadsheet to PNG image arrayapi_response = api_instance.convert_document_ods_to_png(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_ods_to_png: %s\n" % e)

And that’s all there is to it! Your response will include an array of download URLs for each PNG image. No problem.

Image for post
Image for post

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