【发布时间】:2014-08-29 20:52:54
【问题描述】:
这篇文章Connecting to PowerPivot with C# 最接近我的问题,但似乎已经过时了。我尝试了他们在答案中显示的方法,但示例
ThisWorkbook.Connections["PowerPivot Data"].OLEDBConnection.ADOConnection
不返回连接信息,而是异常。
但我能够使用以下方法访问 PP 数据模型:
ThisAddIn.Current.Application.ActiveWorkbook.Connections[1]. ModelTables[1].ModelTableColumns[1].Name`
但是该对象只允许您查看模型中的列名。我无法获取连接信息或任何内容。
ThisAddIn.Current.Application.ActiveWorkbook.Connections[1].ModelConnection.ADOConnection`
导致异常,因此:
ThisAddIn.Current.Application.ActiveWorkbook.Connections[1].OLEDBConnection.ADOConnection
我的问题
- 我的代码有错误吗?
- 还有其他方法可以连接到我上面没有列出的数据模型吗?
- 是否可以读取数据模型中的记录? (我能够读取列名)
感谢您的宝贵时间!
【问题讨论】:
-
也能够连接到这个ThisAddIn.Current.Application.ActiveWorkbook.Model.Name;
标签: c# excel ado powerpivot datamodel