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

Free Support Forum - aspose.com

shape.toImage() fails for shape types other than ChartShape

For regular Excel charts, the Aspose shape.toImage() API seems to work well.
However, there are common cases where the shape being exported is not a plain ChartShape, and for those the shape.toImage() API fails to generate SVG.

One common example is a chart grouped together with some other shape, for example an arrow shape that points the attention to a an interesting value on the chart. Such a shape will be an instance of GroupShape. It seems that for all types except ChartShape, shape.toImage() will silently fall back to producing BMP format.

The interesting thing is that using the SheetRender API will actually export all the shapes on the sheet, including the problematic ones not supported by shape.toImage() to valid SVG. So it seems that at least some part of Aspose Cells does know how to convert such shapes to SVG.

Using the SheetRender API as a workaround introduces some annoyances for us. It would be very convenient if shape.toImage() produced SVG as expected for all shape types.

Hi Taras,


Thank you for contacting Aspose support.

We have evaluated your presented scenario while using the latest version of Aspose.Cells for Java 8.3.1.2 to export Chart grouped with other shapes (tested with arrows) to SVG format. We are unable to replicate the said problem whereas the resultant image is a valid SVG instead of a Bitmap as discussed in your post. We would request you to please give a try to the latest version of Aspose.Cells for Java 8.3.1.2 (link shared above) using the following piece of code against your sample spreadsheet. In case the problem persists, please provide us your spreadsheet along with your code snippet for further investigation.

Java

Workbook excelDocument = new Workbook(“D:/report.xlsx”);
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
imageOrPrintOptions.setSaveFormat(SaveFormat.SVG);
ChartCollection charts = excelDocument.getWorksheets().get(0).getCharts();
for(int i=0;i<charts.getCount();i++)
{
Chart chart = charts.get(i);
chart.toImage(“D:/output” + “i” + “.svg”,imageOrPrintOptions);
}

Hi Babar,

I see you are iterating the ChartCollection in your sample code.
In our scenario, we’re working with different shapes. Some of which might be charts, while others not. It seems, that the shape.toImage() method is only implemented to generate SVG for shapes that are representing charts, and not for other shape types.
Kind regards,
Taras

Hi Taras,


Thank you for more details.

We have re-evaluated the case while using the following piece of code, and have observed that only charts are being saved in SVG format, whereas other shapes are stored in BMP format. We have logged a ticket (CELLSJAVA-41153) in our database to look further into this matter. Please spare us little time to analyze the scenario in more detail to assist you further in this regard.

Java

Workbook excelDocument = new Workbook(“D:/temp/report.xlsx”);
ImageOrPrintOptions imageOrPrintOptions = new ImageOrPrintOptions();
imageOrPrintOptions.setSaveFormat(SaveFormat.SVG);
ShapeCollection shapes = excelDocument.getWorksheets().get(0).getShapes();
for(int i=0;i<shapes.getCount();i++)
{
Shape shape = shapes.get(i);
shape.toImage(“D:/output” + i + “.svg”,imageOrPrintOptions);
}

Hi,


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

We have fixed your issue now.

Let us now your feedback.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-41153) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.