-1
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);
}
}
這是我在Excel中插入file.I標誌形象Java代碼想從URL傳遞路徑,如「http://localhost:8080/Enertech/img/logo.png」 如何重寫上面code.Please幫助我。如何傳遞到InputStream的URL路徑
它給出classNotFound錯誤 –