excel导出图片
2017-05-27 09:38
393 查看
private Drawing patriarch;
//BufferedImage是Image的实现,主要作用就是将一副图片加载到内存中
BufferedImage bufferImg = null;
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
//filepath图片路径
File file=new File(filepath);
if(file.exists()){
InputStream is;
try {
bufferImg = ImageIO.read(file);
ImageIO.write(bufferImg, "jpg", byteArrayOut);
//画图的顶级管理器,一个sheet只能获取一个(一定要注意这点)
is = new FileInputStream(path);
byte[] bytes = IOUtils.toByteArray(is);
//anchor主要用于设置图片的属性
ClientAnchor anchor = helper.createClientAnchor();
// 图片插入坐标
anchor.setCol1(colunm++);
anchor.setCol2(colunm);
anchor.setRow1(row.getRowNum());
anchor.setRow2(row.getRowNum()+1);
row.setHeightInPoints(80);
anchor.setDx1(0);
anchor.setDx2(0);
anchor.setDy1(0);
anchor.setDy2(0);
anchor.setAnchorType(2);
int pictureIdx = this.wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
patriarch.createPicture(anchor, pictureIdx);
fg=false;
val="";
} catch (Exception e1) {
}
}
//BufferedImage是Image的实现,主要作用就是将一副图片加载到内存中
BufferedImage bufferImg = null;
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
//filepath图片路径
File file=new File(filepath);
if(file.exists()){
InputStream is;
try {
bufferImg = ImageIO.read(file);
ImageIO.write(bufferImg, "jpg", byteArrayOut);
//画图的顶级管理器,一个sheet只能获取一个(一定要注意这点)
is = new FileInputStream(path);
byte[] bytes = IOUtils.toByteArray(is);
//anchor主要用于设置图片的属性
ClientAnchor anchor = helper.createClientAnchor();
// 图片插入坐标
anchor.setCol1(colunm++);
anchor.setCol2(colunm);
anchor.setRow1(row.getRowNum());
anchor.setRow2(row.getRowNum()+1);
row.setHeightInPoints(80);
anchor.setDx1(0);
anchor.setDx2(0);
anchor.setDy1(0);
anchor.setDy2(0);
anchor.setAnchorType(2);
int pictureIdx = this.wb.addPicture(bytes, Workbook.PICTURE_TYPE_PNG);
patriarch.createPicture(anchor, pictureIdx);
fg=false;
val="";
} catch (Exception e1) {
}
}
相关文章推荐
- 利用MIME导出多sheet的excel(包含图片)
- C#导出图片到EXCEL
- .net 3种自动导出带图片的excel方法
- C#中GDI+导出excel (含图片, 数据)
- POI导出Excel文件图片丢失问题解决
- 不依赖OFFICE组件实现带图片的EXCEL导出
- Jxls导出excel的若干方式总结(十二)-- 在导出报表中动态插入图片
- asp.net 导出excel 以及插入图片
- java导出excel,以及相关实例jxl ,插入图片,指定格式文字
- C#导出图片到EXCEL
- jasperserver中excel导出图片
- JavaScript能将页面中的图片导出到excel中吗?!!!!!(截出来的)
- 导出含有图片的EXCEL的解决办法
- JAVA_将JFreeChart图片导出到Excel
- jxl 导出excel中图片 行不对应
- 导出图片到Excel-完整Job
- 关于Gridview中使用控件和图片导出到Excel的处理
- 如何利用jxl导出excel图片
- Jxls导出excel的若干方式总结(十)-- 在导出报表中插入单张图片
- POI在导出的EXCEL中嵌入图片