Equivalent of HtmlSaveOptions#setCellCssPrefix() for SheetRender

Hi,

Using Aspose Cells for Java, version 25.1.

When saving parts of a workbook in HTML format, there is the setting HtmlSaveOptions#setCellCssPrefix(). This is very useful, when the generated HTML is embedded inside another HTML document. Since CSS styles are global, using this option we can ensure that there are no CSS style overlaps.

We are looking for a similar option when exporting parts of a workbook to SVG.
Sample code:

Workbook workbook = new Workbook("source.xlsx");
WorksheetCollection worksheets = workbook.getWorksheets();

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

for (int s = 0; s < worksheets.getCount(); s++) {
    Worksheet worksheet = worksheets.get(s);
    SheetRender sr = new SheetRender(worksheet, imgOptions);
    sr.toImage(0, "result-" + worksheet.getName() + ".svg");
}

In the code above, we are exporting two ranges to SVG files.

In the first SVG file, there will be a CSS declaration like the following:

.f0
{
font-family:Aptos Narrow;
font-size:11.039999962px;
fill:#006100;
}

In the second SVG file, there will be a slightly different CSS declaration with the same name:

.f0
{
font-family:Aptos Narrow;
font-size:11.039999962px;
fill:#3F3F76;
}

We are combining this SVG content generated by Aspose Cells into a single HTML file with additional information.

The problem is that there when the two SVGs are combined inside one HTML file, there is a clash between the CSS style names generated by Aspose Cells. The .f0 style from the second SVG will override the .f0 style from the first one.

So the problem is very similar to ones that HtmlSaveOptions#setCellCssPrefix() was designed to solve.
It would be very useful, if ImageOrPrintOptions would have a similar configuration property to setCellCssPrefix, so that we can ensure that the style names exported by Aspose Cells have names that are guaranteed to be unique, and can be safely combined.

Kind regards,
Taras
source.zip (7.8 KB)

@TarasTielkes

We will evaluate this requirement and give feedback soon.

@TarasTielkes
To evaluate the requirement that setting css prefix while rendering sheet to svg image, 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-46245

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.

@TarasTielkes ,

We have added new API: ImageOrPrintOptions.setSvgCssPrefix(String prefix) for your requirements and will be released in next release Aspose.Cells for Java 25.2.

Hi,

Thank you for implementing this improvement.

We have found another issue of a similar nature.
In the SVG generated by Aspose Cells, there will be clipPath elements like these:

<clipPath id="CLIP1">
 <path d="M-0.5,-1.5 L96.5,-1.5 L96.5,45.5 L-0.5,45.5 Z " />
</clipPath>

These are referenced by elements like the following:

<g clip-path="url(#CLIP1)">

When combining multiple SVG files generated by Aspose Cells into a single HTML document, there will be clashes in the HTML model, since every SVG is generating elements with id values like CLIP1, CLIP2, etc.

It would be useful if the configuration property that you’ve introduced would be used to generate guaranteed unique clip-path identifiers. Or alternatively, a new configuration property could be introduced to control that aspect of SVG generation.

Thanks in advance, and kind regards,
Taras

@TarasTielkes
We will evaluate this requirement and try to support it if possible. W 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-46246

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.

@TarasTielkes,

We are pleased to inform you that your issue(Ticket ID: “CELLSJAVA-46246”) has been resolved. The fix will be included in our upcoming release (Aspose.Cells v25.2) that we plan to release in the first half of February 2025. You will be notified when the next version is released.

The issues you have found earlier (filed as CELLSJAVA-46245,CELLSJAVA-46246) have been fixed in Aspose.Cells for Java 25.2.