如何将JSONP拉到工作表 [英] How to pull JSONP to a sheet

查看:87
本文介绍了如何将JSONP拉到工作表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apps for Excel,需要填充一张表格,其中包含由MVC4网络应用程序输出的行。这是跨域的。我看过只有一个示例应用程序通过REST提取YouTube内容而且它不会转换为我的用例。

I'm working with Apps for Excel and need to populate a sheet with rows being output by an MVC4 web-app. It's cross-domain. I've seen only a single sample app pulling YouTube content via REST and it doesn't translate to my use case.

如何点击提供JSON内容的网络应用程序(多个行和列)并将其插入空白表?

How do I hit a web-app that serves JSON content (multiple rows and columns) and insert that to a blank sheet?

推荐答案

您好,¥b $ b您可以参考以下代码进行跨域调用:

Hi,
You can refer to the code below to make a cross-domain call:

function crossDomanAjaxCall() {


.support.cors = true;
.support.cors = true;


.ajax({
contentType:'application / json; charset = utf-8',
url:'http: /www.crossdomain.com/home/data',
类型:'获取',
dataType:'jsonp',
数据:" data",
async:false ,
cache:false
})。success(function(response){
app.showNotification(" Success",response.statusText);
})。error(function) (回复){
app.showNotification(" Error",response.statusText);
});
}
.ajax({ contentType: 'application/json; charset=utf-8', url: 'http:/www.crossdomain.com/home/data', type: 'Get', dataType: 'jsonp', data: "data", async: false, cache: false }).success(function (response) { app.showNotification("Success", response.statusText); }).error(function (response) { app.showNotification("Error", response.statusText); }); }

以下帖子可能会有所帮助:

http://social.msdn.microsoft.com/Forums/en-US/2b431c22-0708-4d2c-b235-6253800246c0/issues-with-performing-an-ajax-call-within-an-office365-app-for -excel?forum = appsforoffice

And the thread below may be helpful:
http://social.msdn.microsoft.com/Forums/en-US/2b431c22-0708-4d2c-b235-6253800246c0/issues-with-performing-an-ajax-call-within-an-office365-app-for-excel?forum=appsforoffice

>>如何点击提供JSON内容(多行和多列)并将其插入空白工作表的Web应用程序?<<

我们无法直接将JSON内容写入工作表。您需要将其解析为字符串或数组。我们可以通过两种方式将数据写入工作表。第一种是使用

setSelectedDataAsync
将数据写入选择值。第二个是使用
Binding.setDataAsync
写数据到绑定对象。

>> How do I hit a web-app that serves JSON content (multiple rows and columns) and insert that to a blank sheet?<<
There is no way we can write the JSON content direct to the worksheet. You need to parse it to the string or array. There is two ways we can write data into the work sheet. The first is using setSelectedDataAsync write data to the select value. And the second is using Binding.setDataAsync write data to the binding object.

祝你好运

Fei


这篇关于如何将JSONP拉到工作表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆