Add a Bitmap as Picture object in Excel workbook in Java

I have a Bitmap that I want to add (as a Picture object) to a new Workbook. I don’t want to save the Bitmap to a file and then read it back in to the Pictures collection. Is there a Picture constructor (or series of steps) to do this?

Hi,

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

You can use the PictureCollection.add() method which takes picture data in the form of stream instead of picture file path.

You can use one of these methods.

Class PictureCollection

java.lang.Object
  extended byCollectionBase
      extended bycom.aspose.cells.PictureCollection


add


public int add(int upperLeftRow, int upperLeftColumn, int lowerRightRow, int lowerRightColumn, java.io.InputStream stream)
       throws java.lang.Exception
Adds a picture to the collection.
Parameters:
upperLeftRow - Upper left row index.
upperLeftColumn - Upper left column index.
lowerRightRow - Lower right row index
lowerRightColumn - Lower right column index
stream - Stream object which contains the image data.
Returns:
Picture object index.




add


public int add(int upperLeftRow, int upperLeftColumn, java.io.InputStream stream)
       throws java.lang.Exception
Adds a picture to the collection.
Parameters:
upperLeftRow - Upper left row index.
upperLeftColumn - Upper left column index.
stream - Stream object which contains the image data.
Returns:
Picture object index.




add


public int add(int upperLeftRow, int upperLeftColumn, java.io.InputStream stream, int widthScale, int heightScale)
       throws java.lang.Exception
Adds a picture to the collection.
Parameters:
upperLeftRow - Upper left row index.
upperLeftColumn - Upper left column index.
stream - Stream object which contains the image data.
widthScale - Scale of image width, a percentage.
heightScale - Scale of image height, a percentage.
Returns:
Picture object index.