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

可能な使用シナリオ

Aspose.Cellsを使用してExcelファイルのページのシーケンスを画像に変換することができます。これにはImageOrPrintOptions.PageIndexおよびImageOrPrintOptions.PageCountプロパティが使用されます。これらのプロパティは、ワークシートに何千ものページがある場合でも、一部のページのみをレンダリングしたい場合に便利です。これにより処理時間の短縮だけでなく、レンダリングプロセスのメモリ消費も節約されます。

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

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

todo:image_alt_text todo:image_alt_text
todo:image_alt_text todo:image_alt_text

サンプルコード

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