We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Image rendered by Aspose has inconsitent border behavior than Excel copy/paste

Hi,

When rendering a worksheet to EMF images, I noticed the border behavior is not consistent with Excel copy as picture + paste.

Code:
var workbook = new Workbook(@".\test.xlsx");
var ws = workbook.Worksheets[0];
ws.PageSetup.PrintArea = @“A1:Q10”;
var options = new ImageOrPrintOptions
{
ImageType = ImageType.Emf,
OnlyArea = false,
TextRenderingHint = TextRenderingHint.ClearTypeGridFit,
OnePagePerSheet = true,
Transparent = true
};

        ws.PageSetup.LeftMargin =
            ws.PageSetup.RightMargin = ws.PageSetup.TopMargin = ws.PageSetup.BottomMargin = ws.PageSetup.HeaderMargin = ws.PageSetup.FooterMargin = 0;
        var render = new SheetRender(ws, options);
        render.ToImage(0, @".\out.emf");

I could see that the border gaps are missing and some characters are touching the border.

I’ve attached my test files and a screenshot for your reference. Could you please take a look?

image.png (52.4 KB)
test.zip (71.3 KB)

Thanks,

@ServerSide527,

Thanks for the template file, sample code, image file and screenshot.

After an initial test, I am able to reproduce the issue as you mentioned by using your sample code with your template file. I found the output image rendered by Aspose.Cells has inconsistent border behavior as you pointed out. I have logged a ticket with an id “CELLSNET-47300” for your issue. We will look into it soon.

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

@ServerSide527,

For the issue:

the border gaps are missing

Microsoft Excel has some special corrections while different style borders connecting each other (see attachment “test border connection.xlsx”), it needs to check borders of surrounding cells while rendering each border. It is complex and costing time.

For the issue:

some characters are touching the border.

The row height is small, a small difference (like one pixel) will cause big difference in the output emf file.

We are sorry that we cannot fix these two issues at the moment. However, in future, if we could evaluate it further or we have some other updates on it, we will let you know.
test border connection.zip (6.7 KB)