Apache POI-HSSF を使用してセルに画像を追加しています。画像は 120x100 ですが、何をどのようにサイズ変更しても、Excel スプレッドシートでは常に複数の行にまたがって表示され、幅よりもはるかに大きな高さに歪んで表示されます。
元のサイズを維持するにはどうすればよいですか?
私のコード:
InputStream is = new FileInputStream(getImageURL());
byte[] bytes = IOUtils.toByteArray(is);
int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
is.close();
//add a picture shape
CreationHelper helper = wb.getCreationHelper();
ClientAnchor anchor = helper.createClientAnchor();
// Create the drawing patriarch. This is the top level container for all shapes.
Drawing drawing = sheet1.createDrawingPatriarch();
//set top-left corner of the picture,
//subsequent call of Picture#resize() will operate relative to it
anchor.setAnchorType(0);
anchor.setCol1(1);
anchor.setRow1(1);
Picture pict = drawing.createPicture(anchor, pictureIdx);
//auto-size picture relative to its top-left corner
pict.resize();
すべての dx/dy 座標と Col/Row を試しました。位置は関係ありません。問題は、画像を水平に引き伸ばすことです。