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)