Web services 在excel中使用webservice并作为一个文件部署
我想从webservice获取一些数据到我的Excel电子表格(Excel 2007)中,但我只想将电子表格部署为一个文件(f.e.Spreadsheet.xlsx-仅此而已) 如果没有这个限制,我会使用VisualStudio插件并用C#编写它,但它会给我一些额外的DLL和vsto文件 在早期版本的excel中,有WebServicesTolkit,但我的研究表明,它在2007年不起作用 有什么解决办法吗?我听说了一些关于MicrosoftOfficeSOAP类型库3.0的事情,但我不知道如何开始使用它Web services 在excel中使用webservice并作为一个文件部署,web-services,excel,excel-2007,vba,Web Services,Excel,Excel 2007,Vba,我想从webservice获取一些数据到我的Excel电子表格(Excel 2007)中,但我只想将电子表格部署为一个文件(f.e.Spreadsheet.xlsx-仅此而已) 如果没有这个限制,我会使用VisualStudio插件并用C#编写它,但它会给我一些额外的DLL和vsto文件 在早期版本的excel中,有WebServicesTolkit,但我的研究表明,它在2007年不起作用 有什么解决办法吗?我听说了一些关于MicrosoftOfficeSOAP类型库3.0的事情,但我不知道如何
任何帮助/示例代码/其他解决方案都将不胜感激。您是否尝试过我了解了如何使用vba中的Ms Office Soap类型库连接webservice-因此没有额外的文件,只有xls(x)。此时,我知道如何获得简单的数据类型结果(如字符串)。但我希望,我能够获得并使用更复杂的类型 代码如下:
Dim webservice As SoapClient30
Dim results As String
' Point the SOAP API to the web service that we want to call...
Set webservice = New SoapClient30
Call webservice.mssoapinit(par_WSDLFile:="{url to wsdl}")
' Call the web service
results = webservice.{method name}()
Set webservice = Nothing
有必要将“Microsoft Office Soap Type Library v3.0”添加到您的工作表参考中。很抱歉,我找到了一篇旧文章,但我最近遇到了类似的限制,所有内容都需要包含在一个工作簿中,并希望发布我的解决方案,以防有人遇到类似问题。最终编写了我自己的全VBA库(主要基于我最喜欢的一个工具RestSharp) 警告,无耻插头: 一些有趣的特性包括身份验证(Http Basic、OAuth1和OAuth2客户端凭据)、异步支持和JSON解析(感谢vba JSON) 它在Excel2010(很可能是2007)中运行得非常好,但由于缺少XMLHTTP库,它在ExcelforMac上不起作用。我已经让它与Salesforce、Trello、Basecamp、GoogleMaps一起使用,它应该与几乎所有REST Web服务一起使用 例如:
Function GetDirections(Origin As String, Destination As String) As String
' Create a RestClient for executing requests
' and set a base url that all requests will be appended to
Dim MapsClient As New RestClient
MapsClient.BaseUrl = "https://maps.googleapis.com/maps/api/"
' Create a RestRequest for getting directions
Dim DirectionsRequest As New RestRequest
DirectionsRequest.Resource = "directions/{format}"
DirectionsRequest.Method = httpGET
' Set the request format -> Sets {format} segment, content-types, and parses the response
DirectionsRequest.Format = json
' (Alternatively, replace {format} segment directly)
DirectionsRequest.AddUrlSegment "format", "json"
' Add parameters to the request (as querystring for GET calls and body otherwise)
DirectionsRequest.AddParameter "origin", Origin
DirectionsRequest.AddParameter "destination", Destination
' Force parameter as querystring for all requests
DirectionsRequest.AddQuerystringParam "sensor", "false"
' => GET https://maps.../api/directions/json?origin=...&destination=...&sensor=false
' Execute the request and work with the response
Dim Response As RestResponse
Set Response = MapsClient.Execute(DirectionsRequest)
If Response.StatusCode = 200 Then
' Work directly with parsed json data
Dim Route As Object
Set Route = Response.Data("routes")(1)("legs")(1)
GetDirections = "It will take " & Route("duration")("text") & _
" to travel " & Route("distance")("text") & _
" from " & Route("start_address") & _
" to " & Route("end_address")
Else
GetDirections = "Error: " & Response.Content
End If
End Function
是的。。。正如我提到的,这个解决方案留给我install.exe、一堆DLL和vsto扩展文件。我想只有一个xlsx文件。谢谢你的关注,我明白了。我不知道它留给你的是install.exe.install.exe?我认为@kMike是指包含部署文件(包括dll)、部署清单、应用程序清单、xlsx文件、相关内容文件等的安装包