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

Free Support Forum - aspose.com

Adding an image to a cell (in java)

I would like to add an image into one cell.
I have come across this topic: Put an image into a cell
But it does not work for me. I am trying to achieve this in Java and I have tried this:

byte[] image = getImage();
InputStream imageStream = new ByteArrayInputStream(image);
sheet.getPictures().add(getRowIndex(), getCellIndex(), getRowIndex(), getCellIndex(), imageStream);

but I get this:

com.aspose.cells.CellsException: Unknown image format:invalid image stream or image format is not supported.

am I missing something?


Thanks for your posting and using Aspose.Cells for Java.

Please use the code in the following article to add image inside the worksheet.


Please try adding the image in these formats. BMP,JPEG,PNG,GIF.

If you want to image in some other format, then please add the JAI library in your classpath and see if it resolves your issue.