تحديد عدد الصفحات المولدة تحويل Excel إلى PDF
Contents
[
Hide
]
في بعض الأحيان، ترغب في طباعة مجموعة من الصفحات إلى ملف PDF الناتج. تحتوي Aspose.Cells على القدرة على تحديد الحد الأقصى لعدد الصفحات التي يتم توليدها عند تحويل جدول بيانات Excel إلى صيغة ملف PDF.
تحديد الحد الأقصى لعدد الصفحات المولدة
المثال التالي يظهر كيفية عرض مجموعة من الصفحات (3 و 4) في ملف Microsoft Excel إلى صيغة 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); |
إذا كان جدول البيانات يحتوي على صيغ، فمن الأفضل استدعاء Workbook.CalculateFormula() قبل عرضه إلى صيغة PDF. القيام بذلك يضمن إعادة حساب القيم التي تعتمد على الصيغ، وتقديم القيم الصحيحة في ملف الإخراج.