ImageOrPrintOptions の PageIndex および PageCount プロパティを使用したページのシーケンスのレンダリング

考えられる使用シナリオ

Aspose.Cells を使用して、Excel ファイルの一連のページを画像にレンダリングできます。ImageOrPrintOptions.PageIndexImageOrPrintOptions.PageCountプロパティ。これらのプロパティは、ワークシートに非常に多くのページ (たとえば数千ページ) があり、その一部のみをレンダリングしたい場合に役立ちます。これにより、処理時間が節約されるだけでなく、レンダリング プロセスのメモリ消費も節約されます。

ImageOrPrintOptions の PageIndex および PageCount プロパティを使用したページのシーケンスのレンダリング

次のサンプル コードは、サンプル Excel ファイルを使用して、ページ 4、5、6、および 7 のみをレンダリングします。ImageOrPrintOptions.PageIndexImageOrPrintOptions.PageCountプロパティ。コードによって生成されたレンダリングされたページを次に示します。

todo:画像_代替_文章 todo:画像_代替_文章
todo:画像_代替_文章 todo:画像_代替_文章

サンプルコード

// 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");
}