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

可能な使用シナリオ

Aspose.Cellsを使用してExcelファイルのページのシーケンスをImageOrPrintOptions.PageIndexおよびImageOrPrintOptions.PageCountのプロパティを使用してイメージにレンダリングできます。これらのプロパティは、ワークシートに多数のページ(数千ページなど)がある場合でも、特定のページのみをレンダリングしたい場合に役立ちます。これにより、処理時間が節約され、レンダリングプロセスのメモリ消費量も節約されます。

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

次のサンプルコードは、サンプルExcelファイルをロードし、ImageOrPrintOptions.PageIndexImageOrPrintOptions.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-.NET
//Source directory
string sourceDir = RunExamples.Get_SourceDirectory();
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
//Load the sample Excel file
Workbook wb = new Workbook(sourceDir + "sampleImageOrPrintOptions_PageIndexPageCount.xlsx");
//Access the first worksheet
Worksheet ws = wb.Worksheets[0];
//Specify image or print options
//We want to print pages 4, 5, 6, 7
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.PageIndex = 3;
opts.PageCount = 4;
opts.ImageType = Drawing.ImageType.Png;
//Create sheet render object
SheetRender sr = new SheetRender(ws, opts);
//Print all the pages as images
for (int i = opts.PageIndex; i < sr.PageCount; i++)
{
sr.ToImage(i, outputDir + "outputImage-" + (i + 1) + ".png");
}