Hi,
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));
sheetRender.ToImage(0).Save("asposeTest.png");
}
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...");
Console.ReadKey();
}
The input and output files are attached.
Thank you,
Ruxandra