This quick tutorial guides to convert XLS to XLSX in Python by loading the source XLS file and saving it back as XLSX or into any other MS Excel supported format. To convert XLS to XLSX Python environment configuration and detailed steps to accomplish the task are shared. You can apply different types of filters while loading the source XLS file and also modify the contents before converting it to XLSX, ODS, CSV, etc.
Steps to Convert XLS to XLSX in Python
- Configure the project for running Aspose.Cells for Python via Java to convert XLS to XLSX
- Create a LoadOptions class object to apply filter while loading the source XLS
- Set filter to load the chart sheets only
- Load the XLS file into Workbook object using the desired filters in the LoadOptions object
- Save the output file as XLSX
These steps show how using Python convert XLS to XLSX by guiding first to establish the environment and then a step-by-step approach to perform the task. It should be noted that it is not necessary to use LoadOptions and you can just load the XLS and then directly save it as XLSX by providing the output file name. However, guidance is provided to filter the contents while loading the XLS file to reduce the processing time and memory requirement before copying the required data to output XLSX.
Code to Convert XLS to XLSX in Python
To convert XLS to XLSX Python code is used that performs necessary imports for required library and classes and then creates the LoadOptions class object where a filter is applied to load the chart sheets only. You can use LoadOptions to load entire data or only shapes, drawings, tables, pictures, etc. You can also set the password to open the XLS file if it is encrypted.
This tutorial has taught us how using Python XLS to XLSX conversion can be performed. If you want to learn the process to convert Excel to PDF, refer to the article on how to convert CSV to Excel in Python.