1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
File file= new File("xxxx");
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
InputStream is = new FileInputStream("chart.png");
byte[] bytes = IOUtils.toByteArray(is);
int pictureIndex = workbook.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
is.close();
CreationHelper helper = workbook.getCreationHelper();
Drawing drawingPatriarch = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(4);
anchor.setCol2(8);
anchor.setRow1(1);
anchor.setRow2(4);
Picture pict = drawingPatriarch.createPicture(anchor, pictureIndex);
pict.resize(); |
Partager