Free Support Forum -

Image from cell reference is truncated when using SheetRender.ToImage


When converting a cell range reference to image using SheetRender.ToImage, the resulting image is truncated.
For reproducing please use the following code:

public const int NormalDpi = 96;

public static ImageOrPrintOptions CreateImageOptions(int? dpi)
var imageDpi = 200;
if (dpi != null)
imageDpi = (int)dpi;

return new ImageOrPrintOptions
Quality = 100,
VerticalResolution = imageDpi,
HorizontalResolution = imageDpi,
PrintingPage = PrintingPageType.IgnoreBlank,
ImageFormat = ImageFormat.Png,
OnePagePerSheet = true,
OnlyArea = true

private static void ExportSnapshot(Workbook workbook, int sheetIndex, int? dpi)
var sheetRender = new SheetRender(workbook.Worksheets[sheetIndex], CreateImageOptions(dpi));

public static double PixelToInch(double pixels)
return pixels / NormalDpi;

private static void Main()
var fileWorkbook = new Workbook(new MemoryStream(File.ReadAllBytes(@"TestFiles\\input.xlsx")));

ExportSnapshot(fileWorkbook, 1, null);

Console.Write("Press any key to exit...");

The input and output files are attached.

Thank you,


Thanks for the template file and sample code.

After an initial test, I observed the issue as you mentioned. I found the output image is truncated and does not cover complete image as per your screen shot. I am using the following sample code with you template file.
Sample code:

Workbook workbook = new Workbook(“e:\test2\input.xlsx”);
Worksheet worksheet = workbook.Worksheets[1];
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();

options.OnePagePerSheet = true;
options.OnlyArea = true;
options.PrintingPage = PrintingPageType.IgnoreBlank;

SheetRender sr = new SheetRender(worksheet, options);

sr.ToImage(0, “e:\test2\outimage1.png”);

I have logged a ticket with an id “CELLSNET-43648” for your issue. We will look into it soon.

Once we have any update on it, we will let you know here.

Thank you.

The issues you have found earlier (filed as CELLSNET-43648) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.