在 xlsx 中添加 PNG 的异常 - Apache POI 3.9 [英] Anomalies adding PNG in xlsx - Apache POI 3.9

查看:32
本文介绍了在 xlsx 中添加 PNG 的异常 - Apache POI 3.9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将 png 添加到我的 xlsx,但有一些异常:在最后一行(仅),图像覆盖在前一行的图像上:

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:

我怀疑是锚定:

    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);

但如果我按照我看到的例子,anchor.setRow1(rowNumber) 那么我的图像根本不显示.

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)?

谢谢.

推荐答案

在尝试了 setColsetRow 的许多排列之后,这最终奏效了:

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);

这篇关于在 xlsx 中添加 PNG 的异常 - Apache POI 3.9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆