Set transparency in SVG

We’re trying to render an SVG of a table (ListObject) using the following code.

PageSetup setup = sheet.getPageSetup();
setup.setPrintArea(tableRange.getAddress());

ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setOnePagePerSheet(true);
options.setImageType(ImageType.SVG);

SheetRender sr = new SheetRender(sheet, options);
sr.toImage(0, "table.svg");

This works well but the problem is that the table’s cells in the generated SVG are transparent unless a cell colour is specified in the excel file. If we make the image type a PNG however, the cells are white in the image and not transparent exactly as we want. We can also see that there is a setTransparency(boolean) function for the ImageOrPrintOptions, but this only works with PNGs and it is false by default anyways.

Is there a way to make it work for SVG as well?

Here is an example of what happens when we try to insert the SVG into a PPT file. Since it is transparent, you can see Powerpoint’s “Click to add Title” text behind the table as it overlaps making the text hard to read too.
Screen Shot 2023-07-31 at 4.55.00 PM.png (642.7 KB)

@5h4fin
Through testing, we can reproduce your issue. When saving the file as SVG, the transparency did not change after setting transparency.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSJAVA-45542

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@5h4fin,

We are pleased to inform you that your issue has been resolved. The fix will be included in an upcoming release ( Aspose.Cells v23.8) that we plan to release in the second week of August 2023. You will be notified when the next version is released.

1 Like

The issues you have found earlier (filed as CELLSJAVA-45542) have been fixed in Aspose.Cells for Java 23.8.