【发布时间】:2015-07-14 22:37:26
【问题描述】:
我需要从 word 文档 (97-2003) 中解析“作者”属性。最好不使用 Word COM-Object。我正在使用 docx-nuget 为 .docx-documents 做同样的事情,但它似乎无法处理旧的 .doc 格式。
我尝试了 Spire.Doc,但免费版本有限(无法打开大型文档),而付费版本对我来说有点太贵了。
有可能做到这一点吗?如果是这样,我如何打开和解析“作者”-属性?
【问题讨论】:
我需要从 word 文档 (97-2003) 中解析“作者”属性。最好不使用 Word COM-Object。我正在使用 docx-nuget 为 .docx-documents 做同样的事情,但它似乎无法处理旧的 .doc 格式。
我尝试了 Spire.Doc,但免费版本有限(无法打开大型文档),而付费版本对我来说有点太贵了。
有可能做到这一点吗?如果是这样,我如何打开和解析“作者”-属性?
【问题讨论】:
我们使用 dsoFile.dll 来读取和写入 doc 文件中的属性。
https://support.microsoft.com/en-us/kb/224351
添加对 Interop.DSOFile 的引用
using DSOFile;
public static string GetAuthorFromFile(string filename)
{
var test = new OleDocumentProperties();
test.Open(filename, true, DSOFile.dsoFileOpenOptions.dsoOptionDefault);
return test.SummaryProperties.Author;
}
见: Why dsofile.dll still need Office Installation?
作为替代方案,您可以使用: http://officefileproperties.codeplex.com/ 但是您还需要在您的应用程序中包含 Office Interop。
【讨论】: