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)