ImageOrPrintOptions の PageIndex および PageCount プロパティを使用したページのシーケンスのレンダリング
Contents
[
Hide
]
考えられる使用シナリオ
Aspose.Cells を使用して、Excel ファイルの一連のページを画像にレンダリングできます。ImageOrPrintOptions.PageIndexとImageOrPrintOptions.PageCountプロパティ。これらのプロパティは、ワークシートに非常に多くのページ (たとえば数千ページ) があり、その一部のみをレンダリングしたい場合に役立ちます。これにより、処理時間が節約されるだけでなく、レンダリング プロセスのメモリ消費も節約されます。
ImageOrPrintOptions の PageIndex および PageCount プロパティを使用したページのシーケンスのレンダリング
次のサンプル コードは、サンプル 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"); | |
} |