Limita il numero di pagine generate Conversione di Excel in PDF
Contents
[
Hide
]
A volte desideri stampare un intervallo di pagine in un file PDF di output. Aspose.Cells for Python via .NET ha la capacità di impostare un limite su quante pagine sono generate durante la conversione di un foglio di calcolo Excel nel formato di file PDF.
Limitazione del numero di pagine generate
L’esempio seguente mostra come rendere un intervallo di pagine (3 e 4) in un file Microsoft Excel in PDF.
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
from aspose.cells import PdfSaveOptions, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Open an Excel file | |
wb = Workbook(dataDir + "TestBook.xlsx") | |
# Instantiate the PdfSaveOption | |
options = PdfSaveOptions() | |
# Print only Page 3 and Page 4 in the output PDF | |
# Starting page index (0-based index) | |
options.page_index = 3 | |
# Number of pages to be printed | |
options.page_count = 2 | |
# Save the PDF file | |
wb.save(dataDir + "outPDF1.out.pdf", options) |
Se il foglio di calcolo contiene formule, è meglio chiamare il metodo Workbook.calculate_formula appena prima di renderizzarlo in PDF. Farlo assicura che i valori dipendenti dalla formula vengano ricalcolati e che i valori corretti vengano renderizzati nel file di output.