我嘗試使用幫助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 –