热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

插件可以沟通吗?连接插件/插件依赖项-Canadd-insCommunicate?ConnectingAdd-ins/Add-inDependency

CanAdd-inscommunicate?插件可以沟通吗?IhaveanExceladdinthatcommunicateswithanAPI.Inthatadd

Can Add-ins communicate?

插件可以沟通吗?

I have an Excel add in that communicates with an API. In that add-in it can take in the XML packaged data as a string and the route of the API as a URL/I as a string then POSTs it data:

我有一个与API通信的Excel插件。在这个外接程序中,它可以将XML打包的数据作为字符串输入,将API的路由作为URL/I作为字符串输入,然后将数据发布到:

Function PostApiXmlToXml(XML as String, URL as String) as String
   'Post to Url that XML data
   'PostApiXmlToXml = the XML response
End Function

The problem is that there are many different routes and functions needed. And not all users need/are authorized to use all Routes.

问题是需要许多不同的路线和功能。并不是所有用户都需要/被授权使用所有的路由。

I either just give everyone access to every function but if they try to send to one they don't have access to it will respond with unauthorized.

我要么让每个人都能访问每个函数,但如果他们试图发送给一个他们无法访问的函数,他们会以未经授权的方式响应。

Or there is a way of having an add in for each function that Connects to the main communication add in?

或者有一种方法可以为每个连接到主通信的函数添加一个add in?

e.g. this separate add-in has a function that is dependent on the first:

例如,这个单独的外接程序有一个依赖于第一个的功能:

Function CalculateSomething(x as double, y as double, z as double) as double
    Xml = "" + x + "" &_
           "" + y + "" &_
           ""  ""       "" "" 
    route = "www.api.com/api/controller/func"
    CalculateSomething = PostApiXmlToXml(xml,route)
End Function

Main problem is that users can opt in to new functions whenever they want, so I want to make it as easy as possible for the user to just download another add-in that will give them access. There's also many more functions to be added in the future.

主要的问题是,用户可以随时选择新功能,所以我想让用户尽可能轻松地下载另一个能让他们访问的插件。将来还会添加更多的函数。

Is it possible or am I going about this all the wrong way?

这是可能的,还是我走错路了?

Would people recommend going down the VSTO route?(no experience in that whatsoever)

人们会建议走VSTO路线吗?(没有任何经验)

1 个解决方案

#1


1  

is a way of having an add in for each function that Connects to the main communication add in?

是否每个连接到主通信的函数都有一个add in?

Assuming CalculateSomething is in one Add-In, and your other function PostApiXmlToXml is in Module1 of a separate Add-in (let's just call it "MainAddIn.xlam" which is already installed on the user's machine)

假设CalculateSomething位于一个外接程序中,而您的另一个函数PostApiXmlToXml位于一个单独外接程序的Module1中(我们姑且称其为“MainAddIn”)。xlam"已经安装在用户机器上)

Function CalculateSomething(x as double, y as double, z as double) as double
    Xml = "" + x + "" &_
           "" + y + "" &_
           ""  ""       "" "" 
    route = "www.api.com/api/controller/func"
    CalculateSomething = _
        Application.Run("MainAddIn!Module1.PostApiXmlToXml", xml, route)
End Function

Note you need to specify the VBProject and Module by name in the Run statement.

注意,您需要在Run语句中按名称指定VBProject和模块。

To check whether the addin is installed you could use a function like this:

要检查插件是否已安装,您可以使用如下功能:

Function IsAddInInstalled(name$) As boolean
Dim a
Dim ret as Boolean
For each a in Application.AddIns
    if (a.Name = name) then
        ret = True
        Exit For
    End If
Next

If not ret Then MsgBox "Please install " & name
IsAddInInstalled = ret
End Function

Deciding where to call this function is another story. Of course you could call it within each procedure in your Dependent add-in, but probably it would be better to put it in the Workbook_Open procedure, just once:

决定调用这个函数的位置是另一回事。当然,你可以在你的附属外接程序中的每个过程中调用它,但是最好将它放在Workbook_Open过程中,只有一次:

Sub Workbook_Open()
    Call IsAddInInstalled("MainAddIn.xlam")
End Sub

This way, every time the user opens Excel, it will check for the availability of the "main" add-in, and raise a message box if it is not available.

这样,每次用户打开Excel时,就会检查“main”外接程序的可用性,如果不可用,就会弹出一个消息框。


推荐阅读
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • 本文讨论了如何在codeigniter中识别来自angularjs的请求,并提供了两种方法的代码示例。作者尝试了$this->input->is_ajax_request()和自定义函数is_ajax(),但都没有成功。最后,作者展示了一个ajax请求的示例代码。 ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • 本文讲述了如何通过代码在Android中更改Recycler视图项的背景颜色。通过在onBindViewHolder方法中设置条件判断,可以实现根据条件改变背景颜色的效果。同时,还介绍了如何修改底部边框颜色以及提供了RecyclerView Fragment layout.xml和项目布局文件的示例代码。 ... [详细]
  • 本文介绍了在SpringBoot中集成thymeleaf前端模版的配置步骤,包括在application.properties配置文件中添加thymeleaf的配置信息,引入thymeleaf的jar包,以及创建PageController并添加index方法。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 本文介绍了Web学习历程记录中关于Tomcat的基本概念和配置。首先解释了Web静态Web资源和动态Web资源的概念,以及C/S架构和B/S架构的区别。然后介绍了常见的Web服务器,包括Weblogic、WebSphere和Tomcat。接着详细讲解了Tomcat的虚拟主机、web应用和虚拟路径映射的概念和配置过程。最后简要介绍了http协议的作用。本文内容详实,适合初学者了解Tomcat的基础知识。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 有没有一种方法可以在不继承UIAlertController的子类或不涉及UIAlertActions的情况下 ... [详细]
  • 利用Visual Basic开发SAP接口程序初探的方法与原理
    本文介绍了利用Visual Basic开发SAP接口程序的方法与原理,以及SAP R/3系统的特点和二次开发平台ABAP的使用。通过程序接口自动读取SAP R/3的数据表或视图,在外部进行处理和利用水晶报表等工具生成符合中国人习惯的报表样式。具体介绍了RFC调用的原理和模型,并强调本文主要不讨论SAP R/3函数的开发,而是针对使用SAP的公司的非ABAP开发人员提供了初步的接口程序开发指导。 ... [详细]
  • 解决文件名过长下载失败问题的jQuery方案
    本文介绍了使用jQuery解决文件名过长导致下载失败的问题。原方案中存在文件名部分丢失的问题,通过动态生成隐藏域表单并提交的方式来解决。详细的解决方案和代码示例在文章中给出。 ... [详细]
author-avatar
姿盛綺妤柏勋
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有