Apache POI - How to put Hyperlink in an image in Excel?

2

This is the method I use to put images in Excel:

public void insertIcons(String URL, Sheet sheet, int colBegin, int colEnd, int rowBegin, int rowEnd) {
    try {
        InputStream iconInput = new FileInputStream(URL);
        byte[] byteTransf = IOUtils.toByteArray(iconInput);
        int pictureIdx = workbook.addPicture(byteTransf, org.apache.poi.ss.usermodel.Workbook.PICTURE_TYPE_PNG);
        iconInput.close();


        CreationHelper helper = workbook.getCreationHelper();
        Drawing drawingIcon = sheet.createDrawingPatriarch();

        ClientAnchor anchorIcon = helper.createClientAnchor();
        anchorIcon.setCol1(colBegin);
        anchorIcon.setCol2(colEnd);
        anchorIcon.setRow1(rowBegin);
        anchorIcon.setRow2(rowEnd);

        Picture iconReady = drawingIcon.createPicture(anchorIcon, pictureIdx);
        iconReady.resize(1);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

So I use the method:

insertIcons(".idea/Icons/table.png", sheetName, 4, 4, 6, 9);

Would it be possible to put a Hyperlink in that image to go to another Sheet on the same worksheet? Or for a website?

I read that apparently apache does not support doing this, but would have like using the lowerLevel API. But I did not get to use it successfully

Some follow up?

    
asked by anonymous 07.01.2018 / 19:28

0 answers