// 插入 PNG 图片至 Excel
InputStream is = new FileInputStream("图片路径");
byte[] bytes = IOUtils.toByteArray(is);
int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
CreationHelper helper = wb.getCreationHelper();
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
// 图片插入坐标
anchor.setCol1(6); //列
anchor.setRow1(0); //行
// 插入图片
Picture pict = drawing.createPicture(anchor, pictureIdx);
pict.resize();
POI 向Excel插入图片
猜你喜欢
转载自blog.csdn.net/woai671/article/details/80170922
今日推荐
周排行