Last active
August 29, 2024 11:10
-
-
Save aspose-com-gists/5d33fa768a61d24704a7350432266781 to your computer and use it in GitHub Desktop.
Excel to Image in Python
This file contains hidden or 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
# load the Excel workbook | |
workbook = Workbook("Book1.xlsx") | |
# create image options | |
imgOptions = ImageOrPrintOptions() | |
imgOptions.setSaveFormat(SaveFormat.SVG) | |
# load the worksheet to be rendered | |
sheet = workbook.getWorksheets().get(0) | |
# create sheet render object | |
sr = SheetRender(sheet, imgOptions) | |
# convert sheet to PNG image | |
for j in range(0, sr.getPageCount()): | |
sr.toImage(j, "WorksheetToImage-out%s" %(j) + ".png") |
This file contains hidden or 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
# load the Excel workbook | |
workbook = Workbook("Book1.xlsx") | |
# create image options | |
imgOptions = ImageOrPrintOptions() | |
imgOptions.setSaveFormat(SaveFormat.SVG) | |
# get sheet count | |
sheetCount = workbook.getWorksheets().getCount() | |
# loop through the sheets | |
for i in range(0, sheetCount): | |
sheet = workbook.getWorksheets().get(i) | |
# convert each sheet to SVG | |
sr = SheetRender(sheet, imgOptions) | |
for j in range(0, sr.getPageCount()): | |
sr.toImage(j, sheet.getName() + "%s" % j + "_out.svg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment