I want to add image to the right side of Header in Excel in java using POI. Below is my sample code
private static void drawImageOnExcelSheet(XSSFSheet sheet, int row, int col, int height, int width, int pictureIdx)
throws Exception {
CreationHelper helper = sheet.getWorkbook().getCreationHelper();
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor1 = helper.createClientAnchor();
anchor1.setAnchorType(AnchorType.DONT_MOVE_AND_RESIZE);
anchor1.setRow2(row); // second anchor determines bottom right position
anchor1.setCol2(col);
anchor1.setDx2(Units.toEMU(width)); // dx = left + wanted width
anchor1.setDy2(Units.toEMU(height)); // dy= top + wanted height
Picture pic = drawing.createPicture(anchor1, pictureIdx);
pic.resize();
}