Begränsa antalet genererade sidor Excel till PDF konvertering
Contents
[
Hide
]
Ibland vill du skriva ut en serie sidor till en utdatan PDF-fil. Aspose.Cells har förmågan att begränsa antalet sidor som genereras vid konvertering av ett Excel-kalkylark till PDF-filformat.
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// 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.PageIndex = 3; | |
// Number of pages to be printed | |
options.PageCount = 2; | |
// Save the PDF file | |
wb.Save(dataDir+ "outPDF1.out.pdf", options); |
Om kalkylbladet innehåller formler är det bäst att anropa Workbook.CalculateFormula() precis innan du renderar det till PDF. Det säkerställer att formelberoende värden beräknas om och de korrekta värdena renderas i den utdatafil som genereras.