0
A
回答
2
给你一个SummaryInformation对象。最后,我找到了答案
这里是代码片段...
File file = null;
FileInputStream fis = null;
HWPFDocument document = null;
Range commentRange = null;
try {
file = new File(fileName);
fis = new FileInputStream(file);
document = new HWPFDocument(fis);
commentRange = document.getCommentsRange();
int numComments = commentRange.numParagraphs();
for (int i = 0; i < numComments; i++) {
String comments = commentRange.getParagraph(i).text();
comments = comments.replaceAll("\\cM?\r?\n", "").trim();
if (!comments.equals("")) {
System.out.println("comment :- " + comments);
}
}
} catch (Exception e) {
e.printStackTrace();
}
我正在使用Poi poi-3.5-beta7-20090719.jar,poi-scratchpad-3.5-beta7-20090717.jar。其他档案 - poi-ooxml-3.5-beta7-20090717.jar和poi-dependencies-3.5-beta7-20090717.zip - 如果您希望在基于OpenXML的文件格式上工作,将需要其他档案。
我很欣赏马克B的帮助究竟是谁发现了这个解决方案....
0
获取HWPFDocument对象(通过在输入流中传递一个Word文档,说的)。
然后你就可以通过getSummaryInformation()得到总结,这将通过getSummary()
+0
非常感谢Brian ... – Garudadwajan 2009-07-15 04:09:56
0
0
我也是新到apache poi。听到是我的程序工作正常这个程序提取word格式的文本到文本...我希望这个程序将帮助你在你运行这个程序之前,你可以在你的类路径中设置相应的lib文件。
/*
* FileExtract.java
*
* Created on April 12, 2010, 9:46 AM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.rtf.RTFEditorKit;
import java.io.*;
import org.apache.poi.POIOLE2TextExtractor.*;
import org.apache.poi.POIOLE2TextExtractor;
import org.apache.poi.POITextExtractor;
import org.apache.poi.extractor.ExtractorFactory;
import org.apache.poi.hdgf.extractor.VisioTextExtractor;
import org.apache.poi.hslf.extractor.PowerPointExtractor;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.extractor.ExcelExtractor;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import javax.swing.text.Document;
/**
*
* @author ChandraMouil V
*/
public class RtfDocTextExtract {
/** Creates a new instance of FileExtract */
static String filePath;
static String rtfFile;
static FileInputStream fis;
static int x=0;
public RtfDocTextExtract() {
}
//This function for .DOC File
public static void meth(String filePath) {
try {
if(x!=0){
fis = new FileInputStream("D:/DummyRichTextFormat.doc");
POIFSFileSystem fileSystem = new POIFSFileSystem(fis);
WordExtractor oleTextExtractor = (WordExtractor) ExtractorFactory.createExtractor(fileSystem);
String[] paragraphText = oleTextExtractor.getParagraphText();
FileWriter fw = new FileWriter("E:/resume-template.txt");
for (String paragraph : paragraphText) {
fw.write(paragraph);
}
fw.flush();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
相关问题
- 1. 阅读java中的excel文件Apache Poi?
- 2. Apache POI注释Excel
- 3. Apache Poi - 如何删除Word文档中的所有链接
- 4. 使用Apache POI从Word文档中读取部分
- 5. 使用Apache POI编辑Word文档
- 6. Apache poi word文档空指针异常
- 7. 使用POI或DOCX4J插入注释到word文档
- 8. 在使用Apache POI和Apache PDF阅读器阅读文档,pdf文件中的错位文本框
- 9. 阅读java中的微软word文档
- 10. 阅读C#中的word文档
- 11. 阅读UWP中的MS WORD文档
- 12. 阅读和Word文档
- 13. 阅读Excel中使用的Apache POI
- 14. 阅读使用Apache POI
- 15. 从apache poi阅读XLSB
- 16. xlsx通过apache poi阅读
- 17. 使用Apache POI的CTPageSZ类中的错误Java NetBeans Word文档
- 18. yardoc:排除来自文档的注释
- 19. 使用Apache Poi解析Word文档中表格中的表格
- 20. 如何阅读Microsoft Word文档中的彩色文本
- 21. 如何使用Apache POI从MS Word文档的文本框中获取文本?
- 22. 如何使用apache poi为word文档设置页边距?
- 23. 如何阅读asp.net中word文档中的复选框
- 24. Word文档的阅读索引(目录)
- 25. 阅读Word文档的Java库
- 26. Word文档中的Apache POI圆形项目符号列表
- 27. 使用Apache POI将任何形状插入到word文档中
- 28. 使用Apache POI在MS Word文档中添加文本
- 29. 如何使用Apache Word POI在word文件中创建Combobox?
- 30. 阅读MS Excel中使用Apache POI
Word文档有多种形式。你能澄清一下你想读的文件类型吗? Word 97/2003 .doc,Word 2007 XML等 – 2009-07-13 14:59:03
我想阅读97/2003/xp和2007 word文件中的评论... – Garudadwajan 2009-07-14 03:47:44