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

查看:94
本文介绍了在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天全站免登陆