日期:2014-05-20  浏览次数:20867 次

终于解决从word中读图片的问题了.POI
推荐http://d.download.csdn.net/source/390900

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import = "java.io.*" %>
<%@ page import = "org.apache.poi.hwpf.*" %>
<%@ page import = "org.apache.poi.hwpf.usermodel.Picture" %>
<%@ page import = "java.util.*" %>
<%
  String sDir = "e:\\test\\"; 
  String sInputDoc = sDir + "abc.doc"; 
  String sImgFile = sDir + "abc2.jpg"; 
   
  HWPFDocument docA = new HWPFDocument(new FileInputStream(sInputDoc));
  List picA=docA.getPicturesTable().getAllPictures();
  Picture p1=(Picture)picA.get(0);
  try {
  p1.writeImageContent(new FileOutputStream(sImgFile));
  } catch (FileNotFoundException e) {
  // TODO Auto-generated catch block
  e.printStackTrace(); } 
   
  String s1=p1.suggestFullFileName();
  String s2=p1.suggestFileExtension();
%>

------解决方案--------------------
厉害,收藏了!!!!!!!
------解决方案--------------------
学习ing