vba 如何在不使用 XML 的情况下通过 excel 将发布请求发送到 RESTful Web 服务?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17707082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to send a post request via excel to a RESTful Web Service without using XML?
提问by Dennis Braga
Here's the deal: I had a excel table that fulfills a MySQL table. I already made a procedure in server side who receives the sheet, read it and put it on the database. Saddly the sheet and data table doesn't have the same structure, so I need to use a php object/script in server side to manipulate it. I have a interface to upload the file (excel file), so the PHP program can read it...
交易如下:我有一个 excel 表,它可以满足 MySQL 表的要求。我已经在服务器端做了一个程序,它接收表单,读取它并将其放入数据库。遗憾的是工作表和数据表没有相同的结构,所以我需要在服务器端使用一个 php 对象/脚本来操作它。我有一个上传文件(excel文件)的接口,所以PHP程序可以读取它...
...but my boss job isn't make my life easier, is it? NO! He says that is a lot of work have to upload every excel file by the web interface. So, he asked me to make a button in the sheet that he might click after his "job" is done. That would replace the web interface. But, the system itself is a interface that would be saled one day (well, it's the plan!). So, I just can't just role out the web interface.
...但我的老板工作并没有让我的生活更轻松,是吗?不!他说通过网络界面上传每个excel文件需要做很多工作。所以,他让我在工作表中制作一个按钮,他可以在他的“工作”完成后点击。那将取代网络界面。但是,系统本身是一个有朝一日会出售的界面(嗯,这是计划!)。所以,我不能仅仅扮演 Web 界面的角色。
WHAT I'M ASKING IS: There's a way that I could send a file (the sheet itself) in a post method straight from the VBA Macro without using XML files and name each data that I'm sending, like a form post?
我在问什么:有一种方法可以直接从 VBA 宏以 post 方法发送文件(工作表本身),而无需使用 XML 文件并命名我发送的每个数据,如表单发布?
So far, I've found some tutorials or even some SO posts that made me get somewhere. But all of them were talking about a XML, and I already have a method that receives a HTTP POST (from a form) and work. I aiming to reuse the same method. From my VBA script I'm already able to make the request (not a big deal) and post it. But, in the server-side script, I'm expecting a POST come out from a form, so it calls a field's name. I don't seen to be able to do that from a VBA post. =/
到目前为止,我已经找到了一些教程,甚至是一些 SO 帖子,它们让我有所收获。但是他们都在谈论 XML,我已经有了一个方法来接收 HTTP POST(来自表单)并工作。我的目标是重用相同的方法。从我的 VBA 脚本中,我已经能够提出请求(没什么大不了的)并发布它。但是,在服务器端脚本中,我期望从表单中发出 POST,因此它调用字段的名称。我没有看到能够从 VBA 帖子中做到这一点。=/