Anomalies adding PNG in xlsx - Apache POI 3.9

百般思念 提交于 2019-12-11 17:44:50

问题


I'm able to add pngs to my xlsx but with a few anomalies: On the last row (only), the image is overlaid on the previous row's image:

I suspect the anchoring:

    int pictureIndex = report.addPicture(curve, XSSFWorkbook.PICTURE_TYPE_PNG);
    anchor.setCol1(7);
    **anchor.setRow1(rowNumber-1);**
    anchor.setCol2(8);
    anchor.setRow2(rowNumber);
    drawing.createPicture(anchor, pictureIndex);

But if I follow the examples I've seen, anchor.setRow1(rowNumber) then my images don't show at all.

Last, is there a way to put the image into a Cell (I would like the option to sort this spreadsheet)?

Thank you.


回答1:


After trying many permutations of setCol and setRow, this eventually worked:

anchor.setCol1(col);
anchor.setRow1(row);
anchor.setCol2(col + 1);
anchor.setRow2(row + 1);


来源:https://stackoverflow.com/questions/54656080/anomalies-adding-png-in-xlsx-apache-poi-3-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!