POI 向Excel插入图片

                        // 插入 PNG 图片至 Excel     		  
  	  		InputStream is = new FileInputStream("图片路径");  
  	  		byte[] bytes = IOUtils.toByteArray(is);    		  
  	  		int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);    		  
  	  		CreationHelper helper = wb.getCreationHelper();  
  	  		Drawing drawing = sheet.createDrawingPatriarch();  
  	  		ClientAnchor anchor = helper.createClientAnchor();   		  
  	  		// 图片插入坐标  
  	  		anchor.setCol1(6);  //列
  	  		anchor.setRow1(0);  //行
  	  		// 插入图片  
  	  		Picture pict = drawing.createPicture(anchor, pictureIdx);  
  	  		pict.resize(); 


你可能感兴趣的:(Java)