我在制作excel表中插入图片时遇到了麻烦。 关于这个问题有很多问题,但我根本无法弄清楚我做错了什么。 我的代码运行,显示没有错误,但我没有看到插入的图像:(
这是代码:
InputStream is = new FileInputStream("nasuto_tlo.png");
byte [] bytes = IOUtils.toByteArray(is);
int pictureIndex = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
is.close();
CreationHelper helper = wb.getCreationHelper();
Drawing drawingPatriarch = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(2);
anchor.setRow1(3);
Picture pict = drawingPatriarch.createPicture(anchor, pictureIndex);
pict.resize();
try {
FileOutputStream out = new FileOutputStream(root+"/Busotina/Busotina1.xls");
wb.write(out);
out.close();
} catch (Exception e) {
e.printStackTrace();
}