Hi,
i’m trying to add a picture from ByteArrayInputStream into the worksheet using the following code:
BufferedImage image = getImage();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write( image, "png", baos);
baos.flush();
byte[] imageInByte = baos.toByteArray();
InputStream is = new ByteArrayInputStream(imageInByte);
baos.close();
Worksheet sheet = workbook.getWorksheets().get(i);
sheet.getPictures().add(0, 0, is);
and i got this:
com.aspose.cells.CellsException: Unknown image format
at com.aspose.cells.zalt.a(Unknown Source)
at com.aspose.cells.zst.a(Unknown Source)
at com.aspose.cells.zsr.a(Unknown Source)
at com.aspose.cells.ShapeCollection.a(Unknown Source)
at com.aspose.cells.ShapeCollection.a(Unknown Source)
at com.aspose.cells.PictureCollection.a(Unknown Source)
at com.aspose.cells.PictureCollection.add(Unknown Source)
Caused by: java.lang.IllegalStateException: End of file reached.
at com.aspose.cells.b.a.d.za.a(Unknown Source)
at com.aspose.cells.b.a.d.za.n(Unknown Source)
at com.aspose.cells.a.d.zcd.h(Unknown Source)
at com.aspose.cells.a.d.zcd.j(Unknown Source)
… 9 more
Can someone tell me what im doing wrong? thanks in advance!
Vincent