This quick tutorial guides on how to create image of spreadsheet using Python. It provides all the necessary details to configure the environment and steps to write an application that can be used to render each page of a spreadsheet as a separate image in an XLSX or XLS file. During this process of generating images of spreadsheets using Python say JPEG images, you will also exercise options to customize the output images.
Steps to Create Excel File in Python
- Configure the development environment to install Aspose.Cells for Python via Java
- Load the input Excel file using the Workbook class object to create spreadsheet images from it
- Instantiate the ImageOrPrintOptions class object to customize the output images
- Set cell auto-fit flag to organize the contents in the cell for better visibility
- Set desired image type
- Get a reference to the target worksheet to be rendered from the loaded workbook
- Parse through all the pages in the spreadsheet and render as a separate image
Here all the steps are designed to cover the complete process of producing spreadsheet picture using Python. All the configuration details, introduction to the required namespaces, classes, methods and enumerators are part of these steps. If you require, you may omit the ImageOrPrintOptions class usage and just render the images with the default settings.
Code to Create an Excel File in Python
If you use ImageOrPrintOptions class object to generate MS Excel sheet image using Python, you can set properties of the output images like setting default font, gridline type, horizontal and vertical resolution, and flag to render the whole worksheet on a single page to name a few. Similarly, the output image type can be set as EMF, JPEG, PNG, BMP, GIF etc. At the end, when all the pages are rendered as images, you may select particular pages as well based on your requirements.
In this tutorial, we have learned to create images from the worksheet. If you are interested in learning the procedure to create an Excel file from scratch, refer to the article on how to create Excel file in Python.