Ответ 1
проблема в том, что ваш якорь неверен. Вам нужно установить все 4 значения, потому что по умолчанию они равны 0, но ваш первый столбец не может быть более правильным, чем ваш второй;) Вы получите отрицательную степень. Вы должны получить предупреждение, когда вы откроете файл excel, который он поврежден.
Итак, попробуйте
anchor.setCol1(2);
anchor.setCol2(3);
anchor.setRow1(3);
anchor.setRow2(4);
Рабочий пример из некоторого кода, который я написал:
// read the image to the stream
final FileInputStream stream =
new FileInputStream( imagePath );
final CreationHelper helper = workbook.getCreationHelper();
final Drawing drawing = sheet.createDrawingPatriarch();
final ClientAnchor anchor = helper.createClientAnchor();
anchor.setAnchorType( ClientAnchor.MOVE_AND_RESIZE );
final int pictureIndex =
workbook.addPicture(IOUtils.toByteArray(stream), Workbook.PICTURE_TYPE_PNG);
anchor.setCol1( 0 );
anchor.setRow1( LOGO_ROW ); // same row is okay
anchor.setRow2( LOGO_ROW );
anchor.setCol2( 1 );
final Picture pict = drawing.createPicture( anchor, pictureIndex );
pict.resize();