消费在Excel Web服务和部署作为一个文件
我想一些数据读取到来自web服务我的Excel电子表格(Excel 2007中),但我想部署电子表格作为一个文件只(FE spreadsheet.xlsx - 仅此而已)。消费在Excel Web服务和部署作为一个文件
如果没有这个限制,我会用Visual Studio的插件,它在C#写的,但它会给我一些额外的DLL和VSTO文件。
在Excel的早期版本,还有Web服务Tolkit,但我的研究表明,它不会与2007年
工作是否有任何解决方案在那里?我听说过有关Microsoft Office Soap Type library 3.0的一些信息,但我不知道如何开始使用它。
任何帮助/样本码/其他解决方案可以理解的。
我了解如何与Web服务与MS Office SOAP类型库在VBA连接 - 所以没有多余的文件,只是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类型库3.0”到工作表的引用。
对不起挖了一个旧的文章,但我最近也有类似的约束一切需要被包含到一个工作簿,并要张贴我的解决方案的情况下,任何人有类似的问题。最终编写了我自己的全VBA库(主要依据我的最爱之一,RestSharp)。
警告,无耻插头:https://github.com/timhall/Excel-REST
一些有趣的功能,包括认证(HTTP基本,您好!OAuth1和OAuth2用户客户端凭证),异步支持和JSON解析(感谢VBA-JSON)
它的工作在Excel 2010中(很可能是2007年)非常棒,但由于缺少XMLHTTP库,无法在Mac上使用Excel。我找到了与Salesforce,Trello,大本营,谷歌地图的工作,它应该与几乎所有的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文件。但感谢您的期待。 – mlusiak 2010-12-22 14:12:19