【发布时间】:2012-10-12 14:18:06
【问题描述】:
我正在尝试使用 JAVA 从文件中获取摘要信息,但我找不到任何东西。我试过 org.apache.poi.hpsf.* 。
我需要作者、主题、评论、关键字和标题。
File rep = new File("C:\\Cry_ReportERP006.rpt");
/* Read a test document <em>doc</em> into a POI filesystem. */
final POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(rep));
final DirectoryEntry dir = poifs.getRoot();
DocumentEntry dsiEntry = null;
try
{
dsiEntry = (DocumentEntry) dir.getEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
}
catch (FileNotFoundException ex)
{
/*
* A missing document summary information stream is not an error
* and therefore silently ignored here.
*/
}
/*
* If there is a document summry information stream, read it from
* the POI filesystem.
*/
if (dsiEntry != null)
{
final DocumentInputStream dis = new DocumentInputStream(dsiEntry);
final PropertySet ps = new PropertySet(dis);
final DocumentSummaryInformation dsi = new DocumentSummaryInformation(ps);
final SummaryInformation si = new SummaryInformation(ps);
/* Execute the get... methods. */
System.out.println(si.getAuthor());
【问题讨论】:
-
你为什么不发布代码,即使它不工作它仍然有助于答案?
-
你说的是 MS Office 文件,对吗?
-
现在我发布代码。不是 MS Office 文件,我说的是一般文件。
-
你的代码有什么问题?它看起来对我来说是正确的?
标签: java apache-poi summary