Konvertera Excel till bild
Contents
[
Hide
]
Konvertera Excel till bild
Aspose.Cells for Python via Java stöder konvertering av Excel-filer till olika bildformer. För detta tillhandahåller APISheetRenderochImageOrPrintOptions klasser. Den här klassen representerar kalkylbladet som kommer att renderas till en bild. DeSheetRenderklass geratt föreställa sig() metod för att konvertera ett kalkylblad till en bildfil. Formaten BMP, PNG, JPEG, TIFF och EMF stöds.
Följande kodavsnitt visar hur du konverterar ett Excel-kalkylblad till en PNG-bild.
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") |