public void insertImage(HSSFWorkbook workbook,HSSFSheet sheet){
try {
InputStream inputStream = new FileInputStream("\\img\\logo.png");
byte[] imageBytes = IOUtils.toByteArray(inputStream);
int pictureureIdx = workbook.addPicture(imageBytes, Workbook.PICTURE_TYPE_PNG);
inputStream.close();
CreationHelper helper = workbook.getCreationHelper();
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(0);
anchor.setRow1(0);
Picture pict = drawing.createPicture(an`enter code here`chor, pictureureIdx);
pict.resize(0.4);
}catch (Exception e) {
System.out.println(e);
}
}这是我的code.Please代码,用于在excel文件中插入徽标图像。我想从网址传递路径,如"http://localhost:8080/Enertech/img/logo.png“如何重写上面的java帮助我。
发布于 2016-07-25 18:49:17
你有没有试着从URL获取一个流?只需尝试更改这一行并检查。
InputStream input = new URL("http://localhost:8080/Enertech/img/logo.png").openStream();https://stackoverflow.com/questions/38565338
复制相似问题