Rendering Slicer
Contents
[
Hide
]
Rendering Slicer
Aspose.Cells for Python via Java stöder rendering av skärform. Följande kodavsnitt laddarexempel på Excel-filsom innehåller en skivare. Den konverterar kalkylbladet till en bild genom att ställa in utskriftsområdet som endast täcker skivan. Den flödande bilden ärutgångsbildsom visar den renderade skivaren. Som du kan se har skivaren renderats på rätt sätt, den ser ut som i exemplet i Excel-filen.
Exempelkod
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
import jpype | |
import asposecells | |
jpype.startJVM() | |
from asposecells.api import Workbook, SaveFormat, ImageOrPrintOptions, ImageType, SheetRender | |
# Load Source Excel file | |
workbook = Workbook("sampleRenderingSlicer.xlsx") | |
# Access first worksheet | |
worksheet = workbook.getWorksheets().get(0) | |
# Set the print area because we want to render slicer only | |
worksheet.getPageSetup().setPrintArea("B15:E25") | |
# Specify image or print options, set one page per sheet and only area to true | |
imgOpts = ImageOrPrintOptions() | |
imgOpts.setHorizontalResolution(200) | |
imgOpts.setVerticalResolution(200) | |
imgOpts.setImageType(ImageType.PNG) | |
imgOpts.setOnePagePerSheet(True) | |
imgOpts.setOnlyArea(True) | |
# Create sheet render object and render worksheet to image | |
sheetrender = SheetRender(worksheet, imgOpts) | |
sheetrender.toImage(0, "outputRenderingSlicer.png") | |
jpype.shutdownJVM() |