使用HTTP Post将数据从excel发送到服务器

use*_*468 1 sql-server asp.net-mvc vba http-post

如何使用HTTP Post从excel发送数据到服务器?

可以说URL是:http:// testingHttpPost /

我想从单元格A2和B2发送数据.我如何在VBA中完成这项工作?

提前致谢

Tim*_*ams 6

Sub XMLPost()
Dim xmlhttp, sData As String

    With ActiveSheet
        sData = "x=" & URLencode(.Range("A2").Value) & _
                "&y=" & URLencode(.Range("B2").Value)
    End With

    Set xmlhttp = CreateObject("microsoft.xmlhttp")

    With xmlhttp
        .Open "POST", " http://testingHttpPost/", False
        .setrequestheader "Content-Type", "application/x-www-form-urlencoded"
        .send sData
        Debug.Print .responsetext
    End With
End Sub
Run Code Online (Sandbox Code Playgroud)

对于URLencode函数,请参见此处:如何在Excel VBA中对字符串进行URL编码?