Reputation: 6888
I am adding an image to the worksheet through some code like this:
// Create the drawing patriarch. This is the top level container for all shapes.
Drawing drawing = sheet.createDrawingPatriarch();
//add a picture shape
//ClientAnchor anchor = this.creationHelper.createClientAnchor();
ClientAnchor anchor = new HSSFClientAnchor((short)0, (short)0, (short)0, (short)0, (short)0, (short)0, (short)2, (short)5)
// 0 = Move and size with Cells, 2 = Move but don't size with cells, 3 = Don't move or size with cells.
anchor.setAnchorType(2)
HSSFPicture pict = drawing.createPicture(anchor, this.images.get("logo"));
pict.resize() ;
However just after the images are added, I resize the columns - which seems to mess things up. It resizes the images - which is not what I want.
//psuedo code
public void autoSizeColumns() {
def cols = (StartColumn..this.cMax)
cols.each { i ->
sheet.autoSizeColumn i
}
}
BrandedWorksheet v;
v.autoSizeColumns()
If I don't perform the autoSizeColumns() the image is the proper size.
Is there any way to have both?
Upvotes: 5
Views: 7649
Reputation: 6888
This is crazy and doesn't make much sense, but allocating the proper amount of spacing and rows seems to be the key. I added enough rows so that the image could be bound internally to the rows - and all seems good.
Moral of the story: keep working and messing about and it may eventually work. You will get really frustrated, and there won't be a ton of help out there - because those of us who have properly sized an image don't really understand why.
Upvotes: 5