On 15/04/2011 12:42, Mark Beardsley wrote:
Some time ago, another post exactly like this one surfaced and we found that
the problem was with the anchor. It actually 'attaches' for want of a better
word, the bottom left hand corner of the image to the top left hand corner
of an adjacent cell. To explain this a little better, imagine that you
inserted an image into cell A1, then the bottom left hand corner of that
image would actually be 'attached' - again for waht of a better word - to
the top left hand corner of cell B2. This allows Excel to stretch the image
if the width of column A is increased or the heigth of row one is likewise
increased. It also seemed to be the reason why the image did not move when
the data was sorted - it was anchored to the top left hand corners of two
cells and Excel did not know how to handle this problem. The solution seemed
to be to change the way the images anchor was created so that you specified
the width and height of the image using Excels co-ordinate system; and I
cannot remember off hand exactly what these values were and so need to look
up some old code. When I get the full information, I will post again later.

The test I conducted to get to this answer was simple. I used POI to insert
images into cells just as you did and confirmed the 'sort proble'. Next, I
simply used Excel to modify the sizes of the images so that they no longer
overlapped the edges of the cell and found that the sort problem was
resolved. It might be worthwhile repeating this test yourself just to make
sure my recollection is correct.

Yes, I tried this and it does then work correctly. Though doing so prevents the images being re-scaled when the row or column size is changed, so its not a realy solution.

So if I understand this and the other posts correctly, then this is a bug that will be fixed in some future release (it is in the pipeline to be resolved?).

As a work around I would be able to make the images smaller so that they were entitely within the cells. But I can't figure out how to do this. I don't seem able to say "anchor to bottom right corner of cell", only to coordinates relative to the top left corner. I also can't specify negative coordinates for the neighboring cell (I tried but it throws exceptions).

Tim




Yours

Mark B

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Anchor-image-to-a-cell-tp4302682p4305346.html
Sent from the POI - User mailing list archive at Nabble.com.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to