我通過一些像這樣的代碼添加到工作表的圖像:POI的Excel HSSFPicture圖片和漿紗
// 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() ;
但是添加圖像剛過,我調整列 - 這似乎把事情搞得一團糟。它調整圖像大小 - 這不是我想要的。
//psuedo code
public void autoSizeColumns() {
def cols = (StartColumn..this.cMax)
cols.each { i ->
sheet.autoSizeColumn i
}
}
BrandedWorksheet v;
v.autoSizeColumns()
如果我不執行autoSizeColumns(),圖像的大小是合適的。
有什麼辦法可以兼得嗎?
你可能不是先大小的列,然後添加圖像在你想要的大小? – Gagravarr 2011-06-02 16:35:16
反向添加圖像的順序和自動調整大小沒有影響... – akaphenom 2011-06-02 17:36:58