Using Aspose.Cells for java 8.4.2.
When I am trying to save XLSX file as html - receive exception. Happens basically on attempt to save image, present inside file into file system.
Test file with problematic image attached. Snippet of code to reproduce this is below:
final static String BASE_FOLDER = “d:\temp\XLSX\”;
public static void main(String[] args) throws Exception
{
FileOutputStream fileOutputStream = new FileOutputStream(BASE_FOLDER + “colored_stream.html”);
PictureIExportObjectListener listener = new PictureIExportObjectListener();
Workbook workbook = new Workbook(BASE_FOLDER + “test2.xlsx”);
HtmlSaveOptions htmlOptions = new HtmlSaveOptions();
htmlOptions.setExportActiveWorksheetOnly(true);
htmlOptions.setExportObjectListener(listener);
workbook.save(fileOutputStream, htmlOptions);
fileOutputStream.close();
}
public static class PictureIExportObjectListener implements IExportObjectListener
{
@Override
public Object exportObject(ExportObjectEvent exportObjectEvent)
{
final Object exportObjectEventSource = exportObjectEvent.getSource();
if (exportObjectEventSource instanceof ChartShape || exportObjectEventSource instanceof Picture
|| exportObjectEventSource instanceof TextBox || exportObjectEventSource instanceof CellsDrawing || exportObjectEventSource instanceof RectangleShape)
{
Picture testShape = (Picture)(exportObjectEventSource);
try
{
OutputStream fileOutputStream = new FileOutputStream(BASE_FOLDER + “pic.png”);
testShape.toImage(fileOutputStream, ImageFormat.getPng());
} catch (Exception e)
{
e.printStackTrace();
}
}
return StringUtils.EMPTY;
}
}