There are situations where you might want to share or display your Excel data in a more accessible or visually appealing format, such as on a website, in a presentation, or within a document. Converting Excel sheets to images is a handy solution, and Python developers can achieve this seamlessly with Aspose.Cells for Python. So let’s explore how to convert Excel sheets to images (PNG, JPEG, SVG, or other) in a Python application.
- Python Excel to Image Converter API
- Convert Excel to Image in Python
- Convert Excel to SVG in Python
- Online Excel to Image Converter
Python Excel to Image Converter
In order to convert Excel’s XLSX or XLS files to image formats, we will use Aspose.Cells for Python via Java. It is a spreadsheet manipulation API that lets you create, modify or convert Excel files. You can install the API using the following command.
pip install aspose-cells
Aspose.Cells for Python via Java supports conversion of Excel files to the following image formats:
Convert Excel to Image in Python
The following are the steps to convert Excel files to an image format, i.e. PNG, JPEG, etc. in Python.
- Load the Excel file using the Workbook class.
- Create an instance of ImageOrPrintOptions class and specify the output image format.
- Access the worksheet you want to convert using Workbook.getWorksheets().get(index) method.
- Create a SheetRender object and initialize it with Worksheet and ImageOrPrintOptions objects.
- Save each page of Excel worksheet as an image using SheetRender.toImage(pageIndex, fileName) method.
The following code sample shows how to convert an Excel worksheet to PNG image.
Python Excel to SVG Conversion
The following are the steps to convert an Excel file to SVG in Python.
- Load the Excel file using the Workbook class.
- Create an instance of ImageOrPrintOptions class and specify the output image format.
- Loop through the worksheets in the Excel file using Workbook.getWorksheets().getCount() method.
- In each iteration, perform the following operations:
- Create a SheetRender object and initialize it with Worksheet and ImageOrPrintOptions objects.
- Save each page of the Excel worksheet as SVG using SheetRender.toImage(pageIndex, fileName) method.
The following code sample shows how to convert Excel to SVG in Python.
Online Excel to Image Converter
Use our free Excel to image converter tool, which is based on Aspose.Cells for Python.
Get Free Excel to Image Converter
You can convert Excel sheets to images without evaluation limitations by getting a free temporary license.
Conclusion
Converting Excel sheets to images using Aspose.Cells for Python is a straightforward process, and it opens up a world of possibilities for presenting your data in various contexts. Whether you want to display your Excel content on a website, incorporate it into a presentation, or use it in a document, Aspose.Cells simplifies the task. With its powerful features and ease of use, Aspose.Cells for Python is a valuable tool for any developer working with Excel files. This step-by-step guide and code samples demonstrated how to convert sheets in an Excel workbook to PNG and SVG formats in Python.
You can explore more about the Python spreadsheet API using the documentation. In case you would have any questions or queries, feel free to let us know via our forum.