عرض تسلسل الصفحات باستخدام خصائص PageIndex و PageCount الخاصة بخيارات ImageOrPrintOptions
Contents
[
Hide
]
سيناريوهات الاستخدام الممكنة
يمكنك عرض تسلسل من صفحات ملف Excel للصور باستخدام Aspose.Cells معImageOrPrintOptions.PageIndexوImageOrPrintOptions.PageCountالخصائص. تكون هذه الخصائص مفيدة عندما يكون هناك العديد من الصفحات على سبيل المثال في ورقة العمل الخاصة بك ولكنك تريد عرض بعضها فقط. لن يؤدي ذلك إلى توفير وقت المعالجة فحسب ، بل سيوفر أيضًا استهلاك الذاكرة لعملية العرض.
عرض تسلسل الصفحات باستخدام خصائص PageIndex و PageCount الخاصة بخيارات ImageOrPrintOptions
يقوم نموذج التعليمات البرمجية التالي بتحميل ملفنموذج لملف Excelويتم عرض الصفحات 4 و 5 و 6 و 7 فقط باستخدام امتدادImageOrPrintOptions.PageIndexوImageOrPrintOptions.PageCountالخصائص. فيما يلي الصفحات المعروضة التي تم إنشاؤها بواسطة الكود.
![]() |
![]() |
---|---|
![]() |
![]() |
عينة من الرموز
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-Java | |
//Load the sample Excel file | |
Workbook wb = new Workbook(srcDir + "sampleImageOrPrintOptions_PageIndexPageCount.xlsx"); | |
//Access the first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Specify image or print options | |
//We want to print pages 4, 5, 6, 7 | |
ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
opts.setPageIndex(3); | |
opts.setPageCount(4); | |
opts.setImageType(ImageType.PNG); | |
//Create sheet render object | |
SheetRender sr = new SheetRender(ws, opts); | |
//Print all the pages as images | |
for (int i = opts.getPageIndex(); i < sr.getPageCount(); i++) | |
{ | |
sr.toImage(i, outDir + "outputImage-" + (i+1) + ".png"); | |
} |