I have created an RTD server for Excel in C# that constantly updates cells with data and needs to work with multiple instances of Excel. The issue is if I have the same RTD formula in more than one instance of Excel and I delete the formula in one of the Excel instances, it calls the DisconnectData method in the RTD server so the identical formulas in the other instances of Excel stop updating even though they should still be updating.
我在C#中为Excel创建了一个RTD服务器,它不断地使用数据更新单元格,并且需要使用多个Excel实例。问题是如果我在多个Excel实例中具有相同的RTD公式并且我在其中一个Excel实例中删除了公式,它会调用RTD服务器中的DisconnectData方法,因此Excel的其他实例中的相同公式会停止更新即使他们仍应该更新。
Is there a way in C# to force each Excel instance to have it's own RTD server or is there a way for the RTD server to properly recognize multiple instances of Excel and check that all instances of a formula have been deleted from all excel workbooks before calling the DisconnectDatamethod in my RTD server.
在C#中是否有一种方法可以强制每个Excel实例拥有自己的RTD服务器,或者RTD服务器是否有办法正确识别Excel的多个实例并在调用之前检查是否已从所有excel工作簿中删除了所有公式实例我的RTD服务器中的DisconnectDatamethod。
2 个解决方案
#1
2
Assuming that your RTD functions are wrapped with a UDF, one solution would be to assign each worksheet an identifier (a Guid, for example) from within the UDF call. You can persist the identifier as a custom worksheet property and then add it to each outgoing RTD topic, which will result in a unique set of topics for each worksheet when they arrive at your RTD server.
假设您的RTD函数包含UDF,一种解决方案是从UDF调用中为每个工作表分配一个标识符(例如Guid)。您可以将标识符保留为自定义工作表属性,然后将其添加到每个传出RTD主题,这将为每个工作表到达RTD服务器时生成一组唯一的主题。
Accessing a custom worksheet property with each RTD call will have a performance impact when processing large numbers of functions, however, so you should cache the identifier for a short period of time to mitigate this. One way to do this is to maintain a dictionary lookup keyed by worksheet object. Within the scope of each UDF call, get the worksheet that the calling cell is associated with via the Application.Caller property (cast it to a Range and get the worksheet property from it), and then lookup the identifier in the dictionary.
但是,在处理大量函数时,访问每个RTD调用的自定义工作表属性会对性能产生影响,因此您应该在短时间内缓存标识符以缓解此问题。一种方法是维护由工作表对象键入的字典查找。在每个UDF调用的范围内,通过Application.Caller属性获取与调用单元关联的工作表(将其强制转换为Range并从中获取工作表属性),然后在字典中查找标识符。
#2
0
I think it is your problem http://support.microsoft.com/kb/284883 How do you register your RTD server? Is it DCOM object?
我认为这是你的问题http://support.microsoft.com/kb/284883你如何注册你的RTD服务器?是DCOM对象吗?
#1
2
Assuming that your RTD functions are wrapped with a UDF, one solution would be to assign each worksheet an identifier (a Guid, for example) from within the UDF call. You can persist the identifier as a custom worksheet property and then add it to each outgoing RTD topic, which will result in a unique set of topics for each worksheet when they arrive at your RTD server.
假设您的RTD函数包含UDF,一种解决方案是从UDF调用中为每个工作表分配一个标识符(例如Guid)。您可以将标识符保留为自定义工作表属性,然后将其添加到每个传出RTD主题,这将为每个工作表到达RTD服务器时生成一组唯一的主题。
Accessing a custom worksheet property with each RTD call will have a performance impact when processing large numbers of functions, however, so you should cache the identifier for a short period of time to mitigate this. One way to do this is to maintain a dictionary lookup keyed by worksheet object. Within the scope of each UDF call, get the worksheet that the calling cell is associated with via the Application.Caller property (cast it to a Range and get the worksheet property from it), and then lookup the identifier in the dictionary.
但是,在处理大量函数时,访问每个RTD调用的自定义工作表属性会对性能产生影响,因此您应该在短时间内缓存标识符以缓解此问题。一种方法是维护由工作表对象键入的字典查找。在每个UDF调用的范围内,通过Application.Caller属性获取与调用单元关联的工作表(将其强制转换为Range并从中获取工作表属性),然后在字典中查找标识符。
#2
0
I think it is your problem http://support.microsoft.com/kb/284883 How do you register your RTD server? Is it DCOM object?
我认为这是你的问题http://support.microsoft.com/kb/284883你如何注册你的RTD服务器?是DCOM对象吗?