Limita il numero di pagine generate - Excel a PDF Conversione
Contents
[
Hide
]
A volte, si desidera stampare un intervallo di pagine su un file di output PDF. Aspose.Cells ha la possibilità di impostare un limite al numero di pagine generate durante la conversione di un foglio di calcolo Excel in PDF.
Limitazione del numero di pagine generate
L’esempio seguente mostra come eseguire il rendering di un intervallo di pagine (3 e 4) in un file Excel Microsoft in PDF.
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 | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(LimitNumberofPagesGenerated.class); | |
// Open an Excel file | |
Workbook wb = new Workbook(dataDir + "TestBook.xlsx"); | |
// Instantiate the PdfSaveOption | |
PdfSaveOptions options = new PdfSaveOptions(); | |
// Print only Page 3 and Page 4 in the output PDF | |
// Starting page index (0-based index) | |
options.setPageIndex(2); | |
// Number of pages to be printed | |
options.setPageCount(2); | |
// Save the PDF file | |
wb.save(dataDir + "outPDF1.pdf", options); |
Se il foglio di calcolo contiene formule, è meglio chiamareWorkbook.calculateFormula appena prima di eseguirne il rendering nel formato PDF. In questo modo si garantisce che i valori dipendenti dalla formula vengano ricalcolati e che i valori corretti vengano visualizzati nel file di output.