2013 C#连接到PowerPivot DataModel [英] 2013 C# connection to PowerPivot DataModel
问题描述
本文使用C#连接到PowerPivot是最接近我的问题但似乎已经过时了。我尝试了他们在答案中显示的方法,但例子
This article Connecting to PowerPivot with C# is the closest to my question but it seems that it is out of date. I attempted the methods they showed in the answer but the example
ThisWorkbook.Connections["PowerPivot Data"].OLEDBConnection.ADOConnection
不返回连接信息,而是异常。
Does not return the connection information, rather an exception.
但是,我可以使用以下方式访问PP数据模型:
But I was able to access the PP Data Model using:
ThisAddIn.Current.Application.ActiveWorkbook.Connections[1]. ModelTables[1].ModelTableColumns[1].Name`
但该对象只允许您查看模型中的列名称。我无法获取连接信息或任何东西。
But the object only allows you to look at the column names in the model. I wasn't able to get the connection information or anything.
ThisAddIn.Current.Application.ActiveWorkbook.Connections[1].ModelConnection.ADOConnection`
引起异常:
ThisAddIn.Current.Application.ActiveWorkbook.Connections[1].OLEDBConnection.ADOConnection
我的问题
- 我的代码有错误吗?
- 是否有另一种连接到上面没有列出的数据模型的方法?
- 是否可以读取数据模型中的记录? (我可以阅读列名)
谢谢你的时间!
推荐答案
string ConnString = Provider = MSOLAP;数据源= $ Embedded $;
区域设置标识符= 1033;位置= + ThisAddIn.Current.Application.ActiveWorkbook.FullName +; SQLQueryMode = DataKeys;
Microsoft.AnalysisServices.Server OlapServer = new Microsoft.AnalysisServices.Server ();
Microsoft.AnalysisServices.Server OlapServer = new Microsoft.AnalysisServices.Server();
OlapServer.Connect(ConnString);
OlapServer.Connect(ConnString);
这篇关于2013 C#连接到PowerPivot DataModel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!