[英]SIMPLE Javascript code to display data from a single field in a Google Spreadsheet
First off, I am NOT a professional programmer, which is why I am here for help, so thanks in advance for your time and patience. 首先,我不是专业程序员,这就是为什么我在这里寻求帮助,所以在此先感谢您的时间和耐心。 I need a bit of code for a website that will call and display information from a specific field in a published Google spreadsheet, to be displayed via HTML, through javascript or some other similar method.
我需要一个网站代码,该网站将调用并显示已发布的Google电子表格中特定字段的信息,并通过HTML,JavaScript或其他类似方法显示。
Looking around, there seems to be several ways of doing this, but all of the examples and tricks I can find are a bit beyond my expertise, and my efforts at applying several of those methods have, frankly, failed miserably. 环顾四周,似乎有几种方法可以做到这一点,但是我可以找到的所有示例和技巧都超出了我的专业知识,坦率地说,我在应用这些方法中的几种方法都失败了。 I have searched through previous questions, but they all cite examples that are way more complicated than what I need.
我已经搜索了先前的问题,但是它们都引用了比我需要的示例更加复杂的示例。
If someone could cite me an easy example, I'd greatly appreciate it. 如果有人可以举一个简单的例子,我将不胜感激。 (The simpler the better.) In the meanwhile, I will continue to experiment to see what I can do.
(越简单越好。)与此同时,我将继续尝试看看自己能做什么。
This is a duplicate of How can I access Google Sheet spreadsheets only with Javascript? 这与“ 如何仅使用Javascript访问Google表格电子表格”重复。
But since that example is not trivial for beginners, here is the code that will show the second cell of the spreadsheet using the code from the answer above 但是,由于该示例对于初学者而言并不简单,因此以下代码将使用上面答案中的代码显示电子表格的第二个单元格
this.jsonCellsUrl = "http://
to this.jsonCellsUrl = "//
and this.jsonCellsUrl = "http://
到this.jsonCellsUrl = "//
this.jsonListUrl = "http://
to this.jsonListUrl = "//
to not have mixed http and https in your page this.jsonListUrl = "http://
到this.jsonListUrl = "//
在页面中没有混合使用http和https <!DOCTYPE html>
<html>
<head>
<title>Spreadsheet example</title>
<script type='text/javascript' src='//code.jquery.com/jquery-1.11.0.js'></script>
<script type='text/javascript' src='google-spreadsheet.js'></script>
<script type='text/javascript'>
$(function() {
var url = "https://spreadsheets.google.com/pub?key=0Ago31JQPZxZrdHF2bWNjcTJFLXJ6UUM5SldEakdEaXc&hl=en&output=html";
var googleSpreadsheet = new GoogleSpreadsheet();
googleSpreadsheet.url(url);
googleSpreadsheet.load(function(result) {
$('#results').html(result.data[1]); // show the 2nd (0-based) cell
});
});
</script>
</head>
<body>
Here is the result: <span id="results"></span>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.