我尝试使用帮助java api Apache POI读取文件.docx。我使用:如何使用apache-poi获取文件的全部内容?
public static String view(String nameDoc){
String text = null;
try{
XWPFDocument docx = new XWPFDocument(
new FileInputStream(nameDoc));
XWPFWordExtractor we = new XWPFWordExtractor(docx);
text = we.getText();
we.close();
docx.close();
}catch (Exception e){
e.printStackTrace();
}
return text;
}
在这种情况下,我得到的只是文件的文本,但我的文件包括文本,表格,图片...我怎样才能得到文件的全部内容?
看到我的答案,它会工作,并帮助你.. –
你是什么意思“文件的全部内容”?例如,我看不出如何在文本字符串中获取图片.... – Gagravarr
此答案应该有所帮助http://stackoverflow.com/a/28304463/1997376 –