Free Support Forum -

How to set the image position


I want to add an image in a ods file .

Here is my code
shapes.addPicture(5, 5, InputStream)

This will insert the image in the cell position E5. But i would like to insert the image where it’s starting position must be in the middle of the cell E5 as in the attached file. How can i do that?

Note : I don’t know the left and top position of the image. Using the cell information i want to set the image position.


Hi Santhosh,

I am afraid, currently we do not have such method to move the Top-Left corner of a picture to the center of any cell. Although we can suggest you two workarounds for your problem.
  1. Irrespective of Cell information, you can move an inserted picture to any XY position on Worksheet plain. Please see SetPositionXY method is Shape Class. [I have attached my output for this method]
  2. We also support to move an inserted picture to centre of a given Cell Range. Please see MoveToCentre method under Shape Class.
Hope it helps.