حفظ كل ورقة عمل في ملف PDF مختلف
Contents
[
Hide
]
تدعم Aspose.Cells تحويل ملفات XLS (التي تحتوي على صور، ورسوم بيانية، إلخ) إلى مستندات PDF. يمكن أن يعمل Aspose.Cells for .NET بشكل مستقل لتحويل جدول بيانات إلى ملف PDF ولا تحتاج إلى استخدام Aspose.PDF for .NET للتحويل. لا يتطلب التحويل إنشاء ملفات مؤقتة أو استخدامها حيث يمكن القيام بالعملية بأكملها في الذاكرة.
حفظ كل ورقة عمل في ملف PDF مختلف
إذا كنت بحاجة إلى حفظ كل ورقة عمل في ملف الإكسيل النموذجي لتوليد ملفات PDF مختلفة، يمكنك تحقيق هذا بسهولة. يمكنك تجربة ضبط رقم الورقة الواحدة إلى الخيار PdfSaveOptions.SheetSet في كل مرة لتقديم إلى 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); | |
// Get the Excel file path | |
string filePath = dataDir + "input.xlsx"; | |
// Instantiage a new workbook and open the Excel, File from its location | |
Workbook workbook = new Workbook(filePath); | |
// Get the count of the worksheets in the workbook | |
int sheetCount = workbook.Worksheets.Count; | |
// Define PdfSaveOptions | |
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
// Take Pdfs of each sheet | |
for (int j = 0; j < sheetCount; j++) | |
{ | |
Worksheet ws = workbook.Worksheets[j]; | |
//set worksheet to output | |
SheetSet sheetSet = new SheetSet(new int[] { ws.Index }); | |
pdfSaveOptions.SheetSet = sheetSet; | |
workbook.Save(dataDir + "worksheet-" + ws.Name + ".out.pdf", pdfSaveOptions); | |
} |
إذا كانت جداول البيانات الخاصة بك تحتوي على صيغ، من الأفضل استدعاء Workbook.CalculateFormula() قبل تحويل جدول البيانات إلى تنسيق PDF. وذلك سيضمن إعادة حساب قيم الصيغ الخاصة وتقديم القيم الصحيحة في الملف الناتج PDF.