1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
String fichierImage = "http://nameServer/output/carte.jpg";
HSSFPatriarch patriarch = sheetCard.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,0,(short)1,1,(short)4,7);
anchor.setAnchorType( 2 );
int pictureIndex;
URL urlFichier = new URL(fichierImage);
BufferedInputStream in = new BufferedInputStream(urlFichier.openStream());
ByteArrayOutputStream bos = null;
try {
bos = new ByteArrayOutputStream();
int c;
while ((c = in.read()) != -1) {
bos.write(c);
}
pictureIndex = wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG);
} finally {
if (in !=null)
in.close();
if (bos != null)
bos.close();
}
HSSFPicture picture = patriarch.createPicture(anchor, pictureIndex);
picture.resize(); |
Partager