首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

Excel 反射 后期绑定 有关问题

2012-02-12 
Excel 反射 后期绑定 问题.Type _excelAppTypeobject _excelobject _documentstry {_excelAppType Ty

Excel 反射 后期绑定 问题.
Type _excelAppType;
object _excel;
object _documents;
try {
_excelAppType = Type.GetTypeFromProgID("Excel.Application",true); 
_excel = Activator.CreateInstance(_excelAppType, false);
_documents = _excelAppType.InvokeMember("Documents",
BindingFlags.GetProperty, null, _excel, null);

} catch (Exception er) {
string result = er.Message;
}
调用_excelAppType.InvokeMember("Documents",BindingFlags.GetProperty, null, _excel, null);
出现错误:Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))

大家有谁遇到过吗?有什么解决办法.

[解决办法]
确实没有Documents属性吧,参考从MSDN上查到的Excel 2007 Object Model,Excel的文档貌似是Workbooks或者Workbook吧……
参考:http://msdn.microsoft.com/zh-cn/library/bb332345(en-us).aspx

热点排行