[英]Make ajax call from Excel Add-in
Is it possible to make ajax calls from Excel 2013 Add-in? 是否可以从Excel 2013加载项进行Ajax调用? If not then what is the best way to create Task Pane for Excel that can do ajax calls?
如果不是,那么为Excel创建可以进行Ajax调用的任务窗格的最佳方法是什么?
Yes I've actually done exactly what you are trying to do. 是的,我实际上已经完全完成了您要尝试做的事情。 Here are some tips
这里有一些提示
btnDownload.Enabled = false;
btnDownload.Enabled = false;
and renable it after execution is completed. My code usually had the following format when doing stuff. 我的代码在执行工作时通常具有以下格式。
// click handler for vsto excel add-in
private async void btnDownload_Click(object sender, RibbonControlEventArgs e)
{
btnDownload.Enabled = false;
using (var client = new HttpClient())
{
var resp = await client.GetAsync("http://somepath.com/data.json");
var statusCode = (int) resp.StatusCode;
if (statusCode == 200)
{
var json = await resp.Content.ReadAsStringAsync();
var jobj = JObject.Parse(json); // from the library I mention.
// lookup docs on how to manipulate jobj
// then make calls to excel api to affect spreadsheet from the json.
}
}
btnDownload.Enabled = true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.