1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > java poi无法读取word_java poi word读取

java poi无法读取word_java poi word读取

时间:2020-10-08 14:40:10

相关推荐

java poi无法读取word_java poi word读取

用 poi 读取word文件 。

老是报错

org.apache.poi.poifs.filesystem.NotOLE2FileException: Invalid header signature; read 0xC9D33C3A6D6F7246, expected 0xE11AB1A1E011CFD0 - Your file appears not to be a valid OLE2 document

public static void readAndWriterTest3() throws IOException {

File file = new File("D:\\jl\\2.doc");

String str = "";

try {

FileInputStream fis = new FileInputStream(file);

HWPFDocument doc = new HWPFDocument(fis);

String doc1 = doc.getDocumentText();

System.out.println(doc1);

StringBuilder doc2 = doc.getText();

System.out.println(doc2);

Range rang = doc.getRange();

String doc3 = rang.text();

System.out.println(doc3);

fis.close();

} catch (Exception e) {

e.printStackTrace();

}

}

文件另存为之后,的word文档,就可以读取。这个要怎么解决,直接为什么读取不了?既然word能打开。为什么poi读取不了?

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。