让她淡淡的来
2019-08-06 16:46
采纳率: 50%
浏览 1.7k
已采纳

poi导出图片到excel ,导出成功但是没有图片,哪位大佬帮助一下

private void drawPictureInfoExcel(HSSFWorkbook wb, HSSFPatriarch patriarch, String pictureUrl, int rowIndex) {
// rowIndex代表当前行
try {
if (pictureUrl != null) {
DataInputStream dis = null;
dis = new DataInputStream(new FileInputStream (URLDecoder.decode("C:/logs/1565079224(1).jpg","UTF-8")));
byte[] data = new byte [1024];
dis.read(data);
// anchor主要用于设置图片的属性
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 1023, 255, (short) 1, rowIndex, (short) 1,rowIndex);
// Sets the anchor type (图片在单元格的位置)
// 0 = Move and size with Cells, 2 = Move but don't size with
// cells, 3 = Don't move or size with cells.
patriarch.createPicture(anchor, wb.addPicture(data, HSSFWorkbook.PICTURE_TYPE_JPEG));
}
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}

debug 图片二进制流是没问题的,但是导出到文档后就如下图所示了!
```![图片说明](https://img-ask.csdn.net/upload/201908/06/1565081165_443823.jpg)
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

相关推荐 更多相似问题