也许这是一个愚蠢的问题,但我找不到解决方法。如何根据图片高度设置行高?以下是我的一部分代码:
int pictureIdx = workBook.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
CreationHelper helper = workBook.getCreationHelper();
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(0);
anchor.setRow1(i);
anchor.setAnchorType(ClientAnchor.MOVE_AND_RESIZE);
HSSFPicture pict = (HSSFPicture) drawing.createPicture(anchor, pictureIdx);
Dimension size = pict.getImageDimension();
double scaledWidth = size.getWidth();
double procentage = (1070.0d * 100d) / scaledWidth;
double autosize = procentage / 100.0d;
pict.resize(autosize);
short h = (short) (pict.getImageDimension().getWidth());
row.setHeight(h);
在 Excel 中,我的图片高度比行高要大得多。