也许这是一个愚蠢的问题,但我找不到解决方案 如何根据图像高度设置行高? 这是我的代码的一部分:
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中,我的图像高度比行高
大得多答案 0 :(得分:2)
怀疑你在一年之后仍然需要它,但是为了它的价值,你将图片宽度指定为行高。
short h = (short) (pict.getImageDimension().getWidth());
另外setHeight使用twip作为单位,即1/20点。因此,您仍然需要将h值乘以20倍以上才能进入像素范围。