Dynamic add a svg picture not work when convert to html

Hi,
I am using aspose-20.12. I want to add a svg picture before save to html. but in the html, can not found the picture.

Workbook workbook = new Workbook("excel-normal3.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);
PictureCollection pictures = worksheet.getPictures();
pictures.add(0, 0, "test.svg");
workbook.save("excel-normal3.html");

upload-aspose.zip (22.8 KB)

@xuerui

It looks like you’re trying to add an SVG image to an Excel worksheet and then save it as an HTML file, but the image isn’t appearing in the output. This issue can occur due to a few reasons, especially with the version you’re using (Aspose.Cells 20.12).

Cause: The problem may stem from the version of Aspose.Cells not fully supporting SVG images, or it could be related to how the images are being saved in the HTML format.

Solution: Here are some steps you can take to troubleshoot and resolve the issue:

  1. Check SVG Support: Ensure that the version of Aspose.Cells you are using supports SVG images. If not, consider updating to a newer version that includes this feature.

  2. Use HtmlSaveOptions: When saving the workbook to HTML, specify options that might help with image handling. For example, set the ExportImagesAsBase64 property to true to embed images directly in the HTML.

    Here’s a code snippet to illustrate this:

    Workbook workbook = new Workbook("excel-normal3.xlsx");
    Worksheet worksheet = workbook.getWorksheets().get(0);
    PictureCollection pictures = worksheet.getPictures();
    pictures.add(0, 0, "test.svg");
    
    HtmlSaveOptions options = new HtmlSaveOptions();
    options.setExportImagesAsBase64(true); // Embed images as Base64
    
    workbook.save("excel-normal3.html", options);
    
  3. Check File Paths: Ensure that the path to the SVG file is correct and accessible. If the file is not found, it won’t be included in the output.

  4. Review Output HTML: After saving, open the generated HTML file and check the image tags to see if the SVG is referenced correctly.

Next Steps: If you follow these steps and still encounter issues, consider checking the Aspose documentation or forums for any specific limitations or additional settings related to SVG images in your version.

Please let me know if you need further assistance!

@xuerui
By testing with sample files and the following sample code on the latest version v25.8, we can reproduce the issue. Image loss when adding svg image to excel file.

Workbook workbook = new Workbook(filePath + "excel-normal3.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);
PictureCollection pictures = worksheet.getPictures();
pictures.add(0, 0, filePath + "test.svg");
workbook.save(filePath + "out_java.xlsx");
workbook.save(filePath + "out_java.html");

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-46471

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.

@xuerui
Your issue(CELLSJAVA-46471) has been resolved and the fixed functionality will be released with version 25.9.
Here is the resulting file generated using the latest function:
CELLSJAVA-46471.zip (7.2 KB)

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