InputStream images = new FileInputStream(image);
byte[] bytes = IOUtils.toByteArray(images);
int pictureIdx = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
CreationHelper helper = workbook.getCreationHelper();
int sheetNos=workbook.getNumberOfSheets();
for(int i=1;i<sheetNos;i++){
Sheet sheet= workbook.getSheetAt(i);
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(8);
anchor.setRow1(0);
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize();
}
ByteArrayOutputStream outputStream=new ByteArrayOutputStream();
workbook.write(outputStream);
java利用POI向excel添加图片
猜你喜欢
转载自849058520.iteye.com/blog/2203303
今日推荐
周排行