【发布时间】:2011-11-23 12:57:12
【问题描述】:
是否可以连接到 Excel .xlsx 文件中的 PowerPivot 模型? (不是托管在 SharePoint 网站上...只是本地文件)。
必须如此,因为 Tableau 可以做到。
谁有线索?
【问题讨论】:
标签: c# excel powerpivot
是否可以连接到 Excel .xlsx 文件中的 PowerPivot 模型? (不是托管在 SharePoint 网站上...只是本地文件)。
必须如此,因为 Tableau 可以做到。
谁有线索?
【问题讨论】:
标签: c# excel powerpivot
简答:
长答案:
参考/致谢:
详情:
像@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 的网站。
【讨论】:
更好的是,看看 Excel Refresh Service on codeplex 的 C# 源代码 - 它演示了如何打开和操作嵌入在 Excel 工作簿中的 PowerPivot 多维数据集。
请注意您所涉及的内容... Excel 自动化有许多怪癖,并且在用作 PowerPivot 多维数据集的管道时往往不稳定。
【讨论】: