poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dudgeon <tdudg...@informaticsmatters.com>
Subject Anchor image to a cell
Date Thu, 14 Apr 2011 10:26:32 GMT
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 
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);
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?


To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

View raw message