ResimOluşturYazdırOptions ın PageIndex ve PageCount Özelliklerini Kullanarak Sayfaların Sıralı Olarak Görüntülenmesi

Olası Kullanım Senaryoları

Aspose.Cells ile Excel dosyanızın sayısız sayfaları olsa da bunlardan sadece bazılarını oluşturmak istiyorsanız, ImageOrPrintOptions’ın ImageOrPrintOptions.PageIndex ve ImageOrPrintOptions.PageCount özelliklerini kullanarak sayısal bir dizi oluşturabilirsiniz. Bu özellikler, iş sayfanızda çok fazla örneğin binlerce sayfa olsa da sadece bazılarını oluşturmak istiyorsanız faydalıdır. Bu, sadece işleme süresini değil aynı zamanda oluşturma sürecinin bellek tüketimini de kaydedecektir.

Görüntü veya Yazdırma Seçenekleri Kullanılarak Sayfa Dizisi Oluşturma

Aşağıdaki örnek kod, ImageOrPrintOptions.PageIndex ve ImageOrPrintOptions.PageCount özelliklerini kullanarak örnek Excel dosyasını yükler ve yalnızca 4, 5, 6 ve 7 sayfaları oluşturur. İşte kod tarafından oluşturulan sayfaların oluşturulmuş görüntüleri.

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

Örnek Kod

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