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

Free Support Forum - aspose.com

Unexpected grid lines appeared in svg converted from Excel worksheet using Aspose.Cells

Hi,

When rendering a range of Excel worksheet to SVG image, I noticed some unexpected white gird lines appeared.

Code:
var workbook = new Workbook(@".\test2.xlsx");
var options = new ImageOrPrintOptions
{
SaveFormat = SaveFormat.SVG,
ImageType = ImageType.Svg,
OnlyArea = false,
TextRenderingHint = TextRenderingHint.ClearTypeGridFit,
OnePagePerSheet = true,
Transparent = true
};
var sheet = workbook.Worksheets[0];
sheet.PageSetup.PrintArea = “A1:E1”;
SheetRender render = new SheetRender(sheet, options);
render.ToImage(0, @".\out.svg");

I’ve attached the test documents for your reference and a screenshot with the extra lines highlighted.

test.zip (6.5 KB)
image.png (36.0 KB)

When I rendered the same worksheet&range to other vector image format (EMF) using Aspose, it doesn’t have the issue.

The Aspose’s ability of rendering the worksheet to SVG is very interesting but this issue seems to be a bit blocking. Could you please help me take a look?

Thanks,

@ServerSide527,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46589 - Unexpected grid lines appeared in SVG converted from Excel worksheet

@ServerSide527,

We fill the cell color one by one. Following is the path record in SVG:
path_start_end.png (22.3 KB)

You can see that the cell fill paths are one by one, the end of left cell fill path is the start of right cell fill path. There should be no white space between cell fill paths. But the white space appears when you open the SVG in browser.

We will let you know if we find more info.

Hi,

Thanks for the explanation.

I have taken some further look and I tried to add a little offset at the beginning and ending of the two cells, and the result then became ok:

image.png (17.7 KB)

Do you think if this can be done automatically in the Aspose rendering process (maybe only when the line start and end are of the same value, and the background is colored)?

Thanks,

@ServerSide527,

Thanks for the screenshot.

Good to know by adding a little offset for the cells works for your needs.

We cannot say anything at the moment. Let us analyze your issue and other aspects thoroughly. Once we have an update on it, we will let you know

@ServerSide527,

Please try to add borders with the same color as the fill color to the cell(s) (see attachment “test2_add_border.xlsx”), the output SVG file seems ok to us.

Do you think if this can be done automatically in the Aspose rendering process (maybe only when the line start and end are of the same value, and the background is colored)?

Adding such an offset in this case will make our API too complex. Let us try to research why the white space appears when the line start and end are the same value in SVG first. Once we have an update on it, we will let you know here.
test2_add_border.zip (6.1 KB)

Many thanks for your suggestion.

As we are automatically rendering different worksheets to images, we cannot predict whether/when to create borders for each cell, also adding borders sometimes changes the margin of the text resulting in different layout in the final output, therefore, we’d like to wait for the update on the SVG issue.

Thanks,

@ServerSide527,

Thanks for sharing your concerns.

Sure, we will update you once there is some new information or update available. Hopefully we will figure it out soon.

@ServerSide527,

After some more research, it seems that it is the anti aliasing that is causing this issue. So we can add ‘shape-rendering=“crispEdges”’ to turn the anti aliasing off. see ref document: https://www.w3.org/TR/SVG11/painting.html#ShapeRenderingProperty

It works ok in Chrome, FireFox and Safari browser types, see attachment “out_shape_rendering.svg” for your reference. But it does not work in IE and Edge browser, see the ref page:

If you can ignore IE and Edge browser and live with it, we can add ‘shape-rendering=“crispEdges”’ attribute for you. By the way, some news about IE and Edge browser as we found:
“Internet Explorer is a compatibility solution,” rather than a browser that businesses should be using day to day for all web browsing activity. Microsoft Edge is planned to be rebuild to base Chromium project.
add_shape_rendering.png (22.6 KB)
out_shape_rendering1.zip (1.1 KB)

Hi,

Many thanks for your suggestions, the information is very helpful.

I have also done some experiment myself, turning off anti aliasing indeed helped the gap issue with Chrome, FireFox and Safari, however, as described in the property, it has lower quality for chart slash lines because anti-aliasing has been turned off:

image.png (68.7 KB)
svg files.zip (7.3 KB)

I understood IE and Edge browser has worse compatibility than others and Edge is to be rebuilt based on Chromium so the browser compatibility is less of my concern, while the aliasing issue seems to be more visible. To me, technically, under this solution we need to balance between the accuracy (the grid line) and the quality (the slash line).

If there’s no other choices available to get rid of the line without losing the quality, would it be possible to make this optional (maybe somewhere in the ImageOrPrintOptions) so developers can decide whether/when to turn off/on this property?

Thanks,

@ServerSide527,

Thank you for providing more information. We have logged your requirement along with the ticket and will consider it while working on this issue.

@ServerSide527,

We can add ‘shape-rendering="crispEdges"’ to let it only effect on cell fill paths (cell background) as per the attachment “out_shape_rendering.svg” shared in the previous post. Then it will not effect on other elements of the chart. Also, we make a test file with chart for comparisons (check the attached zipped archive “test2_chart.zip”). You will find one with ‘shape-rendering="crispEdges"’(see the “out_chart_shaperendering.svg” in the zipped archive), the another one is rendered without ‘shape-rendering="crispEdges"’(see “out_chart.svg” in the zipped archive). You will see ‘shape-rendering="crispEdges"’ only effects on cell background, the charts are always ok.
test2_chart.zip (19.4 KB)

Thanks @Amjad_Sahi

This sounds/looks very promising indeed. Many thanks for your investigations.

I’m looking forward to seeing this feature available in Aspose.Cells.

Regards,

@ServerSide527,

Sure, we will keep you posted with latest updates (e.g supported version, details, etc.) once available.

@ServerSide527,

Please try our latest version/fix: Aspose.Cells for .NET v19.2.1:

Aspose.Cells19.2.1 For .Net2_AuthenticodeSigned.Zip (4.7 MB)
Aspose.Cells19.2.1 For .Net4.0.Zip (4.8 MB)

Your issue should be fixed in it.

Let us know your feedback.

Hi @Amjad_Sahi

After an initial test, it seems to work fine with the samples I currently have.

I will let you know if I found any problems with other documents, but it is indeed looking good so far. Thanks very much for the quick implementation.

@ServerSide527,

Good to know that your issue is sorted out by the new fix/version. Sure, take your time to evaluate the fix, hopefully it will work fine for other documents.

The issues you have found earlier (filed as CELLSNET-46589) have been fixed in Aspose.Cells for .NET v19.3. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi