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.
如果我不执行autoSizeColumns(),则图像大小合适。
Is there any way to have both?
有没有办法同时拥有两者?
1 个解决方案
#1
5
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.
故事的道德:继续工作和搞乱,它可能最终奏效。你会感到非常沮丧,并且那里没有大量的帮助 - 因为我们这些有正确尺寸图像的人并不真正理解为什么。
#1
5
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.
故事的道德:继续工作和搞乱,它可能最终奏效。你会感到非常沮丧,并且那里没有大量的帮助 - 因为我们这些有正确尺寸图像的人并不真正理解为什么。