如何在Excel中保留Excel Ribbon Addin的数据 [英] How can I persist data for an Excel Ribbon Addin in Excel

查看:217
本文介绍了如何在Excel中保留Excel Ribbon Addin的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Excel功能区插件,需要在Excel会话之间保留用户选择。使用自定义XML部件似乎是最好的选择。但是,我不能得到这个工作,没有得到COMExceptions。

I have created an Excel ribbon addin which needs to persist user selections between Excel sessions. Using custom XML Parts seems to be the best option for this. However I can't get this to work without getting COMExceptions.

MSDN文档是不是很有用(http://msdn.microsoft.com/en-us /library/bb608612.aspx)。有人可以给我一个在Excel Ribbon addin中进行这个工作的例子吗?

The MSDN docs are just not very useful (http://msdn.microsoft.com/en-us/library/bb608612.aspx). Can someone give me an example of making this work in an Excel Ribbon addin?

推荐答案

我知道有三种不同的方法:

There are three different methods I know of:

自定义XML部分
对于应用程序级别的添加,这是我首选的存储任何需要的应用程序数据的方法保存在保存的xls文件中,而不会对用户可见。

Custom XML parts For an application-level add in, this is my preferred method of storing any application data that needs to be persisted in a saved xls file without ever being visible to the user.

http://msdn.microsoft.com/en-us/library/bb608612.aspx

缓存数据群岛
这仅适用于文档级添加。如果您尝试在应用程序级别的添加中使用它,您将获得例外。

Cached Data Islands This only works for document-level add ins. You will get exceptions if you try to use it in an application-level add in.

http://blogs.msdn.com/b/eric_carter/archive/2004/04/23/119294.aspx

隐藏工作表
使用VSTO,您可以创建用户无法看到的隐形工作表。这样做很好,但是导致了很多尴尬的编码,将您的数据转换成Excel表格。

Hidden worksheet Using VSTO, you can create invisible worksheets that cannot be seen by users. This works well, but leads to a lot of awkward coding to convert your data to fit in an excel sheet.

更新(2014):
所以最终使用自定义XML部件被证明是一个性能问题,所以我的应用程序必须改回来使用隐藏的工作表。显然,一旦XML达到一定的大小,Excel就会变得非常缓慢。我的加载项具有自定义部件达到数千个节点,而且XML的增长越大,Excel中的所有就越慢。例如,只需点击任何单元格就会产生非常明显的延迟。

Update (2014): So in the end the usage of Custom XML parts turned out to be a performance issue so my application had to be changed back to use hidden worksheets. Apparently, once the XML reaches a certain size, Excel becomes very sluggish. My add-in had Custom Parts reach thousands of nodes, and the larger the XML grew, the slower everything in Excel became. For example, simply clicking on any cell would incur a very noticeable delay.

这篇关于如何在Excel中保留Excel Ribbon Addin的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆