Eseguire il rendering della sequenza di pagine utilizzando le proprietà PageIndex e PageCount di ImageOrPrintOptions
Contents
[
Hide
]
Possibili scenari di utilizzo
È possibile eseguire il rendering di una sequenza di pagine del file Excel in immagini utilizzando Aspose.Cells conImageOrPrintOptions.PageIndexeImageOrPrintOptions.PageCountproprietà. Queste proprietà sono utili quando ci sono così tante, ad esempio migliaia di pagine nel tuo foglio di lavoro, ma vuoi renderizzare solo alcune di esse. Ciò non solo salverà il tempo di elaborazione, ma salverà anche il consumo di memoria del processo di rendering.
Eseguire il rendering della sequenza di pagine utilizzando le proprietà PageIndex e PageCount di ImageOrPrintOptions
Il codice di esempio seguente carica il fileesempio di file Excele visualizza solo le pagine 4, 5, 6 e 7 utilizzando l'ImageOrPrintOptions.PageIndexeImageOrPrintOptions.PageCountproprietà. Ecco le pagine renderizzate generate dal codice.
![]() |
![]() |
---|---|
![]() |
![]() |
Codice d’esempio
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Load the sample Excel file | |
Workbook wb = new Workbook(srcDir + "sampleImageOrPrintOptions_PageIndexPageCount.xlsx"); | |
//Access the first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Specify image or print options | |
//We want to print pages 4, 5, 6, 7 | |
ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
opts.setPageIndex(3); | |
opts.setPageCount(4); | |
opts.setImageType(ImageType.PNG); | |
//Create sheet render object | |
SheetRender sr = new SheetRender(ws, opts); | |
//Print all the pages as images | |
for (int i = opts.getPageIndex(); i < sr.getPageCount(); i++) | |
{ | |
sr.toImage(i, outDir + "outputImage-" + (i+1) + ".png"); | |
} |