如何从外部应用程序调用 Excel VSTO 函数?
我正在寻找一种可以自动化 Excel VSTO 文档级解决方案的方法,从外部应用程序调用,类似于 VBA 方法,例如我们用来自动化 VBA 的“xlApp.Run("WorkBook", "MacroName") 解决方案,因此我不选择使用 VSTO 2010 和针对 Excel 2007 和 2010 版本的框架 4。
由于这将是一个文档级 名为“TestBook”的工作簿的解决方案,其中包含基于 VSTO 的类“MyClass”和静态函数“GetData(字符串连接)” 我正在寻找一种从外部应用程序调用 GetData 函数的方法解决方案本身。也将使用 Application.Workbooks.Open 方法由外部应用程序加载到 Excel 中。
总结一下:我正在尝试找到一种方法来获取对对象的引用(理想情况下)并从文档级解决方案中调用函数。加载后我正在尝试两者。像(外部应用程序)->(插件)->(文档级别对象)这样的方式,但路线(外部应用程序)->(文档级别对象)将是理想的。
任何指示将不胜感激。
I am looking for a way I can automate an Excel VSTO Document level solution, to be called from an external application, similar to the VBA approach like "xlApp.Run("WorkBook", "MacroName") which we use to auto mate VBA solutions. As this will be a document level solution, Remoting or Webservices are not options. I am using VSTO 2010 and Framework 4 targeting Excel 2007 and 2010 versions.
Say, I have a Document Level Solution with a workbook named "TestBook" which contains a VSTO based class "MyClass" with a static function "GetData(string connection)" I am looking for a way to make a call to GetData function, from an external application. The solution itself will be loaded into excel by the external application too using Application.Workbooks.Open method.
To summarize: I am trying to find a way to get a reference to an object (ideally) and make a call to a function from a Document level solution after loading it. I am trying both ways like (External App)->(Addin)->(Document level object) but the route (External App)->(Document level Object) would be ideal.
Any pointers would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑您需要以不同的方式解决这个问题...
以您希望的方式调用方法,您可能会诉诸称为“COM Automation AddIn”的东西并以这种方式实现 UDF。
然后,您可以将对方法的调用作为该工作簿的任何销售中的公式进行调用 - Excel 通过调用您的实现来评估该公式。您甚至可以告诉 Excel 重新评估它。
另一种选择可能是将功能构建为工作簿中引用的所谓 RTD 服务器...
有关某些信息,请参阅以下链接:
I suspect you need to go about this a bit differently...
The call a method the way you want you might a to resort to something called a "COM Automation AddIn" and implement a UDF this way.
You can then just place the call to your method as a formula inside any sell of that workBook - Excel eveluates that formula by calling your implementation. You can even tell Excel to reevaluate it.
Another option might be to build the functionality as a so-called RTD-server which is referenced in your workbook...
For some information see these links: