Hi,
When converting a table to image using SheetRender.ToImage in the resulted image the table has white borders on left and bottom sides.
For reproducing the issue please use the attached file and the following code:
var excelDocument = new Workbook(“excel.xlsx”);
var worksheet = excelDocument.Worksheets[0];
var imageOptions = new ImageOrPrintOptions
{
Quality = 100,
VerticalResolution = 200,
HorizontalResolution = 200,
PrintingPage = PrintingPageType.IgnoreBlank,
ImageFormat = ImageFormat.Png,
OnePagePerSheet = true,
OnlyArea = true
};
const int startRow = 18;
const int startColumn = 7; //h
const int endRow = 22;
const int endColumn = 8; //i
var startColumnAsLiteral = CellsHelper.ColumnIndexToName(startColumn);
var endColumnAsLiteral = CellsHelper.ColumnIndexToName(endColumn);
worksheet.PageSetup.PrintArea = string.Format("{0}{1}:{2}{3}", startColumnAsLiteral, startRow + 1, endColumnAsLiteral, endRow + 1);
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.BottomMargin = 0;
var sheetRender = new SheetRender(worksheet, imageOptions);
Image image = sheetRender.ToImage(0);
image.Save(“testImage.png”, ImageFormat.Png);
Best regards,
Aurelian Iordache
Software Developer
IBM Romania
Hi Aurelian,
Thanks for your posting and using Aspose.Cells.
Please download and try the latest version: Aspose.Cells for .NET 8.4.0 and see if it makes any difference and resolve your issue.
I have executed your code with the latest version and it generated the correct image which I have attached for your reference.
Hi Shakeel,
The issue is almost solved but there are still small white borders on the left and the lower edges of the image, could you please check this ? A better way to see them is to place the image on a dark background.
Thank you,
Aurelian Iordache
Software Developer
IBM Romania
Hi Aurelian,
Hi Aurelian,
Hi,
Thanks for your using Aspose.Cells.
Please download and try the latest fix: Aspose.Cells for .NET v8.5.0.2 and let us know your feedback.
Hi Shakeel,
I tested with v.8.5.0.2 and I confirm the remaining issue is solved.
I’m attaching the resulted image here for your reference.
So I assume the fix will be present in the next public release.
Thank you very much !
Best regards,
Aurelian Iordache
Software Developer
IBM Romania
Hi Aurelian.
Hi,
This issue was fixed 8.5.0.2 but reappeared in Aspose Cells 8.5.0. Please investigate. Thanks!
Hi,
The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan