How to Convert ODS to XLSX in Python
2 min readJul 3, 2020
File format conversion in Python is a tricky business at the best of times, but rises to new levels of difficulty when working with spreadsheets. Trust me when I say that you do not want to manually approach conversion between ODS format to XLSX. But that’s OK, because the work has already been done for you. To get access to these results, you just need to make use of a Cloudmersive API.
Let’s start by installing our API client:
pip install cloudmersive-convert-api-client
Now for our function call:
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 XLSXapi_response = api_instance.convert_document_ods_to_xlsx(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_ods_to_xlsx: %s\n" % e)
And if you go ahead and run this code, you will soon see that your input ODS file has been converted into an XLSX. Easy!