是否可以连接到 Excel .xlsx 文件中的 PowerPivot 模型? (不托管在 SharePoint 网站上...只是本地文件)。
一定是,因为 Tableau 可以做到。
有人知道吗?
最佳答案
简答:
- 是
长答案:
- 更新版本的 Excel 或 PP(甚至可能是 Office 服务包?)可能会破坏您的代码
- 我们成功地使用 AMO 连接到 PP 模型(将表添加到数据源 View 、添加维度、添加度量并从外部数据库刷新模型)。我们发现 codeplex ( https://tabularamo2012.codeplex.com/) 上的表格 AMO 库非常有用。
- 我们成功地使用 ADO(但不是 ADOMD)连接到 PP 模型以查询模型(例如,查询度量值)。
引用/学分:
- https://gobansaor.wordpress.com
- http://sqlblog.com/blogs/default.aspx
- http://powerpivotgeek.com/2009/11/11/a-peek-inside-the-client-architecture/#comments
详细信息:
与@gobansaor 一样,我们发现从一个已经连接到 PP 缓存的工作簿开始是有帮助的(有必要吗?)。例如,在通过 AMO 连接到 PP 缓存之前,我们确保连接处于事件状态:
ThisWorkbook.Connections["PowerPivot Data"].Reconnect()
或
ThisWorkbook.Connections["PowerPivot Data"].Refresh()
我们用于 AMO 的连接字符串模板是:
Provider=MSOLAP;Data Source=$Embedded$;Locale Identifier=1033;Location={0};SQLQueryMode=DataKeys
我们用ThisWorkbook.FullName
填充
在@gobansaor 之后,我们使用以下方法通过 ADO 连接到多维数据集:
ADODB.Recordset recordSet = new ADODB.Recordset();
recordSet.Open("SELECT [Measures].[Min of Field1] ON COLUMNS FROM [Model]", ThisWorkbook.Connections["PowerPivot 数据"].OLEDBConnection.ADOConnection);
关于c# - 使用 C# 连接到 PowerPivot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8242557/