是否可以连接到 Excel .xlsx 文件中的 PowerPivot 模型?(不托管在 SharePoint 网站上......只是本地文件)。
必须如此,因为 Tableau 可以做到。
有人有任何线索吗?
是否可以连接到 Excel .xlsx 文件中的 PowerPivot 模型?(不托管在 SharePoint 网站上......只是本地文件)。
必须如此,因为 Tableau 可以做到。
有人有任何线索吗?
简短的回答:
长答案:
参考文献/学分:
细节:
像@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 Data"].OLEDBConnection.ADOConnection);
您可以构建 VSTO 插件。
这是一个帮助解释如何使用 PowerPivot 和 VSTO 的站点。
Better yet, take a look at the C# source code of the Excel Refresh Service on codeplex - which demonstrates how to open and manipulate PowerPivot cubes that are embedded in Excel workbooks.
Be aware of what you're getting into... Excel automation has many quirks and tends to be unstable when used as a conduit into a PowerPivot cube.