Is it possible to make ajax calls from Excel 2013 Add-in? If not then what is the best way to create Task Pane for Excel that can do ajax calls?
Yes I've actually done exactly what you are trying to do. Here are some tips
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.