Access Google-apps public spreadsheet via Javascript

北慕城南 提交于 2019-11-30 07:33:48

Google provide a documented way to access google spreadsheet via JSONP that works for normal gmail.com accounts. In short:

To access this from within JavaScript you'll have to insert a HTML script tag into your document:

<script src="https://spreadsheets.google.com/feeds/cells/0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE/od6/public/values?alt=json-in-script&callback=myCallback"></script>

And you'll need to implement the callback function in your webpage:

function myCallback(spreadsheetdata) {
  // do something with spreadsheet data here
  console.log(spreadsheetdata);
}

You can simplify this with jQuery:

var url = "https://spreadsheets.google.com/feeds/cells/0AmHYWnFLY1F-dG1oTHQ5SS1uUzhvTnZTSHNzMjdDaVE/od6/public/values?alt=json-in-script&callback=?";
$.getJSON(url,{}, function (d) { console.log(d); });

I have implemented a fairly complete example and the code is at https://bitbucket.org/tbrander/ggadget/wiki/Home Code is BSD license (except for Trademarks and institutional markings which are all rights reserved) It is reasonably well commented... It is in operation at http://acre.cba.ua.edu/ (bottom of page) Stand alone at : http://acre.cba.ua.edu/mobiletool/res.html

It functions across IE, Chrome FF i-Phone and Android Your hints above are close but I was looking for yet more... as You can now see,, But I will explore the Jquery syntax as the current implementation is pure JS

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!