Begränsa antalet genererade sidor Excel till PDF konvertering
Contents
[
Hide
]
Ibland vill du skriva ut en rad sidor till en utdata-PDF-fil. Aspose.Cells för Python via .NET har möjlighet att sätta en gräns för hur många sidor som genereras när du konverterar ett Excelfil till PDF-filen.
Begränsning av antalet genererade sidor
Följande exempel visar hur man renderar en rad sidor (3 och 4) i en Microsoft Excel-fil till 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
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) |
Om kalkylarket innehåller formler är det bäst att anropa Workbook.calculate_formula metoden precis innan det renderas till PDF. Att göra detta säkerställer att formelberoende värden omräknas, och de korrekta värdena renderas i utdatafilen.