Convert Excel to Image
Contents
[
Hide
]
Convert Excel to Image
Aspose.Cells for Python via Java supports converting Excel files to different image forms images. For this, the API provides the SheetRender and ImageOrPrintOptions classes. This class represents the worksheet that will be rendered to an image. The SheetRender class provides the toImage() method for converting a worksheet to an image file. BMP, PNG, JPEG, TIFF, and EMF formats are supported.
The following code snippet demonstrates converting an Excel worksheet to a PNG image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source_directory = "Examples/SampleFiles/SourceDirectory/" | |
output_directory = "Examples/SampleFiles/OutputDirectory/" | |
workbook = Workbook(source_directory + "Book1.xlsx") | |
imgOptions = ImageOrPrintOptions() | |
imgOptions.setImageFormat(ImageFormat.getPng()) | |
sheet = workbook.getWorksheets().get(0) | |
sr = SheetRender(sheet, imgOptions) | |
for j in range(0, sr.getPageCount()): | |
sr.toImage(j, output_directory + "WToImage-out%s" %(j) + ".png") |