我正在尝试使用poi将图像显示到Excel工作表中。这是源代码:
//...reading inputStream
byte[] bytes = IOUtils.toByteArray(inputStream);
//Debugging shows that pictureIdx value is 0
int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
Drawing drawing = sheet.createDrawingPatriarch();
CreationHelper helper = workbook.getCreationHelper();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(1);
anchor.setRow1(1);
Picture pict = drawing.createPicture(anchor, pictureIdx);
//...Saving workbook
当我打开生成的excel文件时,没有显示图像,而是我收到此错误消息:
Repaired records: Drawing from /xl/drawings/drawing1.xml-Part (Drawingsform)
任何帮助将不胜感激。非常感谢。
p.s:我使用的是Java 8和MS Excel 2013