Hi all,
I'm anchoring images to a cell in Excel sheet using HSSFClientAnchor.
Its mostly going OK, but I see strange behaviour in Excel related to sorting. I have one column in sheet that contains images, and other columns that contain corresponding text or numeric data corresponding the image.
The images are anchored using MOVE_AND_RESIZE.
The anchor is created like this:

int row = ...;
int col = ...;
int index = workbook.addPicture(image, format);
anchor = new HSSFCLientAnchor(0,0,0,0, (short)col, row, (short) (col + 1), row + 1);
anchor.setAnchorType(MOVE_AND_RESIZE);
patriarch.createPicture(anchor, index);


When the column or row heights are changed the images resize correctly.

When the sheet is filtered the correct images are associated with the correct cells.

When the sheet is sorted the images do not move according the the new sorted order.

It seems to me that the way Excel does sorting and filtering is different. When data is filtered the displayed row numbers change. e.g. the row numbers can now be 1,5,7,8,11,13... and the appropriate image is still displayed against each row.

However when the data is sorted the row numbers are 1,2,3,4,5,6,7... and the wrong (original) image is associated with the row.

So this looks to me like an inconsistency in Excel, but I thought I'd ask if there were any suggestions for getting this working better with POI?

Thanks
Tim




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

Reply via email to