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

Free Support Forum - aspose.com

Convert excel to svg issue

Hello. I followed an example but it didnt work for me. I am trying to convert a xls file to svg but the svg image file ends up blank. Also I whant to convert into a single svg file and not one svg per sheet. Here is my code:


Workbook workbook = new Workbook(path);

//Convert each worksheet into svg format in a single page.
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setSaveFormat(SaveFormat.SVG);
imgOptions.setOnePagePerSheet(true);

//Convert each worksheet into svg format
int sheetCount = workbook.getWorksheets().getCount();

for(int i=0; i<sheetCount; i++)
{
Worksheet sheet = workbook.getWorksheets().get(i);

SheetRender sr = new SheetRender(sheet, imgOptions);

for (int k = 0; k < sr.getPageCount(); k++)
{
//Output the worksheet into Svg image format
sr.toImage(k, path + sheet.getName() + k + “.svg”);
}
}

Hi,


I think you may try the following sample code to render SVG file format for the underlying Workbook:
e.g
Sample code:

Workbook wb = new Workbook(“f:\files\Book1.xlsx”);
SvgSaveOptions options = new SvgSaveOptions(SaveFormat.SVG);
wb.save(“f:/files/outBook1.svg”, options);


If you still find the issue, kindly provide your sample Excel file and output SVG file here, we will check it soon.

Thank you.

Hello, thanks for the quick reply. I had tried that, but these errors occured:


Exception in thread “main” java.lang.NoClassDefFoundError: com/sun/media/imageio/plugins/tiff/TIFFImageWriteParam
at com.aspose.cells.zbir.a(Unknown Source)
at com.aspose.cells.SheetRender.a(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)

Caused by: java.lang.ClassNotFoundException: com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam


Hi,


Thanks for the template file and error trace.

After an initial test, I got the exception “java.lang.NoClassDefFoundError: com/sun/media/imageio/plugins/tiff/TIFFImageWriteParam” when saving the workbook to SVG file format. It seems it is requiring “jai_imageio.jar” file but it is required to render TIFF images via Aspose.Cells APIs. Even we do set the jai jar to class path yet the output SVG file is some how blank and the contents are not rendered fine.
e.g
Sample code:

Workbook wb = new Workbook(“teste.xls”);
SvgSaveOptions o = new SvgSaveOptions(SaveFormat.SVG);
wb.save(“f:/files/out1.svg”, o);

I have logged a ticket with an id “CELLSJAVA-41155” for your issue. We will look into it to figure it out soon.

Thank you.

Hi,


Please try our latest version/fix: Aspose.Cells for Java v8.3.1.5

Well, we do not support to save the whole workbook to SVG file. We support to save
the whole workbook to a tiff file using workbookRender.toImage API.

Please use the following sample code:

e.g

Sample code:


<span style=“font-family:“Calibri”,“sans-serif”;color:black”>
Workbook wb = new Workbook(srcFile);<o:p></o:p>

<span style=“font-family:“Calibri”,“sans-serif”;color:black”>
ImageOrPrintOptions options = new ImageOrPrintOptions();<o:p></o:p>

<span style=“font-family:“Calibri”,“sans-serif”;color:black”>
options.setImageFormat(ImageFormat.getTiff());<o:p></o:p>

<span style=“font-family:“Calibri”,“sans-serif”;color:black”>
WorkbookRender wbRender = new WorkbookRender(wb, options);<o:p></o:p>

<span style=“font-family:“Calibri”,“sans-serif”;color:black”>
wbRender.toImage(outFile.tiff);<o:p></o:p>

By the way, please do not forget to add the external jar (JAI jar(s)).


Thank you.