I do not think it is a bug, rather that is how Excel works; I guess I am
saying that there is a trade off - to get the images to re-size, they need
to be 'attached' to the adjoining cells but doing so prevents the sort from
working correctly. Honestly, I cannot think of any way that POI could be
changed to circumvent this problem as it is a 'feature' of the Excel
application itself I believe. It might be worth playing around with the
image sizes in Excel just to ensure that I am correct, but I do think that
as soon as the image is wholly contained within the cell - so to speak - the
sort will work but re-sizing will fail and once the image overlaps so that
it is attached to the adjoining cell, the reverse will hold true. Further, I
would ask this question on an Excel forum just to make sure that my
POIcentric view of events is actually accurate.

As to the offsets, I have not had the chance to look at my old code yet so
cannot provide a definitive answer. If I am correct, you need to use the
first four paramaters of the anchor to set the x and y coordinates for the
top left and bottom right hand corners of the image. There are maxima for
the coordinates of the bottom right hand corner of the image which I cannot
remember off hand but I do know that HSSF enforces them so the best advise
is to try a few values and see what happens. From memory, the exception
message includes the maximum value.

If you want the top left hand corner of the image to be inside another cell,
then provide the co-ordinates for the position within the cell as the first
two - I think - arguments to the anchor and the index for the cell as
arguments number 5 and 6. As you say, you cannot use negative numbers and so
will have to combine setting two 'sets' of arguments so that they work
together.

Yours

Mark B

PS Even if the image is not 'attached' to the adjoining cell, it still ought
to shrink in size - I think - and it will grow in size also until it reaches
it's full size.

--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Anchor-image-to-a-cell-tp4302682p4307172.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