如何样能让poi读取的word按原来的格式显示在页面
1个回答
2017-01-04 · 知道合伙人软件行家
关注
展开全部
怎么样能让poi读取的word按原来的格式显示在页面
因为poi读取word 没法读取到空格和回车.这个问题要如何解决呢
poi java
------解决方案--------------------
public static void main(String[] args) {
File file = new File("D:/test.doc");
try {
FileInputStream fis = new FileInputStream(file);
HWPFDocument hwpfd = new HWPFDocument(fis);
WordExtractor wordExtractor = new WordExtractor(hwpfd);
String[] paragraph = wordExtractor.getParagraphText();
for (int i = 0; i < paragraph.length; i++) {
System.out.println(paragraph[i]);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
因为poi读取word 没法读取到空格和回车.这个问题要如何解决呢
poi java
------解决方案--------------------
public static void main(String[] args) {
File file = new File("D:/test.doc");
try {
FileInputStream fis = new FileInputStream(file);
HWPFDocument hwpfd = new HWPFDocument(fis);
WordExtractor wordExtractor = new WordExtractor(hwpfd);
String[] paragraph = wordExtractor.getParagraphText();
for (int i = 0; i < paragraph.length; i++) {
System.out.println(paragraph[i]);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询