更改 PowerPivot 文件中的连接数据
所以我遇到了一个有趣的问题。我需要在 PowerPivot 查询中指定自定义 WHERE 子句。我必须根据外部条件来改变它。我想编辑该文件并保存副本。知道如何做到这一点吗?我从二进制文件打开了 PowerPivot 文件,但它似乎已加密...
So I've run into an interesting problem. I need to specify a custom WHERE clause in a PowerPivot query. I must change it based on external conditions. I would like to edit the file and save a copy. Any idea how to do this? I opened the PowerPivot file from binary, but it appears encrypted...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以转到现有连接,然后在那里进行更新。如果您再次打开相同的数据源(SQL、SSRS 或其他任何数据源)而不是更改现有连接上的参数,则会降低性能,因为 PowerPivot 会将这些数据视为单独的连接。
You can go to existing connections, and then make an update there. If you open the same data source (SQL, SSRS, or anything else) again instead of changing parameters on the existing connection, it will slow your perf as PowerPivot will treat those as separate connections.
解决方案是以 Zip 形式打开 Excel 工作簿(使用 Package 类)。
如果您想修改查询,则可以。 /xl/customData/item1.data 处的文件是一个备份文件,代表用于处理查询的 PowerPivot 数据库(只是在 Vertipaq 模式下运行的 Analysis Services 数据库)。您需要将文件恢复到在 Vertipaq 模式下运行的 SSAS 实例。完成后,将查询编写为 ALTER 脚本。修改脚本(在本例中,将 @projectId 替换为我的实际项目 ID),然后针对数据库运行它们。完成所有这些后,备份数据库并放回到 Excel 工作簿中。这会修改查询。
连接数据存储在 /xl/connections.xml 文件中。打开它,修改并替换。再次重新打包,现在您又拥有了一本工作簿。
这是我制作的代码。您必须根据需要调用这些方法。基本的想法已经有了,但是......
Solution was to open the Excel workbook up as a Zip (using the Package class).
If you are looking to modify the queries, you can. The file at /xl/customData/item1.data is a backup file that represents the PowerPivot database (which is just an Analysis Services database running in Vertipaq mode) used to process queries. You need to restore the file to a SSAS instance running in Vertipaq mode. Once that's done, script the queries as an ALTER script. Modify the scripts (in this case, replacing @projectId with my actual projectID), then run them against the database. Once all this is done, back the database up and put back into the Excel workbook. That modifies the queries.
The connection data is stored in the /xl/connections.xml file. Open that up, modify, and replace. Repack it all up again, and now you have a workbook again.
Here's the code I made. You will have to call the methods as you need. Basic idea is there, though...