积极答复者
求助,关于用c#提取word文档内置属性问题

问题
-
代码如下:
System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using word =Microsoft.Office.Tools.Word;
using Office = Microsoft.Office.Interop.Word;
using core = Microsoft.Office.Core;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Object FileName = "d:\\1.doc";
Object missing = System.Reflection.Missing.Value;
Office.Application app = new Microsoft.Office.Interop.Word.Application();
app.Visible = true;
Office.Document document = app.Documents.Open(ref FileName, ref missing, ref missing, ref missing
, ref missing, ref missing, ref missing, ref missing
, ref missing, ref missing, ref missing, ref missing
, ref missing, ref missing, ref missing, ref missing)
core.DocumentProperties prps = (core.DocumentProperties)document.BuiltInDocumentProperties;
}
}
}但是调试时,老显示 document.BuiltInDocumentProperties无法转换为 DocumentProperties,不支持此接口,但是我查阅一些资料,代码确实是这样编写的,请高手指教
答案
-
非常感谢几位朋友给我的回答,最近我也查阅了一些资料,他们说BuiltInDocumentProperties返回的类型是DocumentProperties,但是实际上它返回的是object类型,通过强制转换,是无法转换成DocumentProperties,显示不匹配,另外,正常情况下,DocumentProperties的类型应该是集合,但是office文档显示的是接口。通过这几天琢磨,可以通过openxml方式调用office文档内置属性。再次感谢Charles Shao
、络绎 两位朋友。
- 已标记为答案 KeFang Chen 2010年5月3日 7:40
全部回复
-
非常感谢几位朋友给我的回答,最近我也查阅了一些资料,他们说BuiltInDocumentProperties返回的类型是DocumentProperties,但是实际上它返回的是object类型,通过强制转换,是无法转换成DocumentProperties,显示不匹配,另外,正常情况下,DocumentProperties的类型应该是集合,但是office文档显示的是接口。通过这几天琢磨,可以通过openxml方式调用office文档内置属性。再次感谢Charles Shao
、络绎 两位朋友。
- 已标记为答案 KeFang Chen 2010年5月3日 7:40