Reputation: 397
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?
Upvotes: 1
Views: 643
Reputation: 4007
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;
}
Upvotes: 2