log.error("图片写入Execl 开始 {}", " 路径:" + imgPath);
BufferedImage bufferedImage = ImageIO.read(new File(imgPath));
// 将BufferedImage转换为JPEG
ByteArrayOutputStream jpegStream = new ByteArrayOutputStream();
ImageIO.write(bufferedImage, "jpeg", jpegStream);
byte[] pictureData = jpegStream.toByteArray();
log.error("图片写入Execl 正常:{}", " 路径:" + imgPath + "byte:" + pictureData.toString());
CreationHelper helper = workbook.getCreationHelper();
Drawing<?> drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(col); // 起始列
anchor.setRow1(row); // 起始行
anchor.setCol2(col); // 结束列
anchor.setRow2(row); // 结束行
Picture picture = drawing.createPicture(anchor, workbook.addPicture(pictureData, Workbook.PICTURE_TYPE_JPEG));
picture.resize(1, 1);
把图片转成jpeg 写入Execl
有其他办法的话 求告知