使用word转换成html常见问题:版本、图片无法显示问题。
- 版本
异常:(The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF))
1、判断文件类型是03版本的word,还是07版本。
String wordURL=""; //WORD 地址
String htmlURL=""; //html 地址
File file=new File(wordURL);
InputStream inputStream =new FileInputStream(file);
String fileName=file.getName();
String fileTyle=fileName.substring(fileName.lastIndexOf("."),fileName.length());
if (".doc".equals(fileTyle)) { // word 03 版本
docToHtml(inputStream, htmlURL);
} else if (".docx".equals(fileTyle)) {// word 07 版本
docx2Html(inputStream, htmlURL);
}