Java Poi 导出失败问题
程序是在网上看的,poi在addPicture时就报错,一直过不了。直接上代码ByteArrayOutputStreambyteArrayOut=newByteArray...
程序是在网上看的,poi在addPicture时就报错,一直过不了。
直接上代码
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
BufferedImage bufferImg = ImageIO.read(new File("d:\\2.jpg") );
ImageIO.write(bufferImg,"jpg",byteArrayOut);
//设置图片大小,位置
HSSFClientAnchor anchor = new HSSFClientAnchor(1,1,1,1,(short) 1,1,(short)1,1);
anchor.setAnchorType(0);
patriarch.createPicture(anchor , wb.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));
报下以错误
java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.addPicture(HSSFWorkbook.java:1610)
at com.excel.action.poiExcelExport.moldInfoTableExport(poiExcelExport.java:55) 展开
直接上代码
ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
BufferedImage bufferImg = ImageIO.read(new File("d:\\2.jpg") );
ImageIO.write(bufferImg,"jpg",byteArrayOut);
//设置图片大小,位置
HSSFClientAnchor anchor = new HSSFClientAnchor(1,1,1,1,(short) 1,1,(short)1,1);
anchor.setAnchorType(0);
patriarch.createPicture(anchor , wb.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG));
报下以错误
java.lang.ClassNotFoundException: org.apache.commons.codec.digest.DigestUtils
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.addPicture(HSSFWorkbook.java:1610)
at com.excel.action.poiExcelExport.moldInfoTableExport(poiExcelExport.java:55) 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询