How to convert Legacy XLS 97–03 Spreadsheet to Excel XLSX in Python

Cloudmersive
2 min readMay 21, 2020

Today is the last day that you will ever have to deal with old, outdated XLS files. I am going to demonstrate for you how to use Python to convert these relics into modern XLSX format, and do so in double quick time. Here we go.

We are going to be using the Cloudmersive API client for documents, which we can install using pip install:

pip install cloudmersive-convert-api-client

And now we are going to call convert_document_xls_to_xlsx, as you can see in the following example setup:

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 XLSXapi_response = api_instance.convert_document_xls_to_xlsx(input_file)pprint(api_response)except ApiException as e:print("Exception when calling ConvertDocumentApi->convert_document_xls_to_xlsx: %s\n" % e)

And just like that, no more outdated files! In fact, this library also contains functions for updating legacy DOC, XLS, and PPT files into their modern counterparts as well.

--

--

Cloudmersive

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