【发布时间】:2019-09-18 13:58:38
【问题描述】:
我们已经在几个项目中使用 Tabletop 作为从 Google 表格访问少量数据的简单方法。
这是来自Tabletop.js Github ReadMe的示例代码:
function init() {
Tabletop.init( { key: 'https://docs.google.com/spreadsheets/d/0AmYzu_s7QHsmdDNZUzRlYldnWTZCLXdrMXlYQzVxSFE/pubhtml',
callback: function(data, tabletop) {
console.log(data)
},
simpleSheet: true } )
}
window.addEventListener('DOMContentLoaded', init)
这是我的示例数据源:https://docs.google.com/spreadsheets/d/1atRxZ4IgQPo5z5-DV7okHdtml8e3VdPjpuiEhwvU8FI/pubhtml
但是当我尝试执行这个测试代码时:https://jsfiddle.net/BaronGrivet/oqnx2sjc/
<div id="data">
<strong>Data should appear here: </strong>
</div>
function init() {
Tabletop.init( {
key: 'https://docs.google.com/spreadsheets/d/1atRxZ4IgQPo5z5-DV7okHdtml8e3VdPjpuiEhwvU8FI/pubhtml',
callback: function(data, tabletop) {
console.log(data)
document.getElementById('data').innerHTML += data
},
simpleSheet: true } )
}
init()
控制台出现如下错误:
加载资源失败:服务器响应状态为 500 () https://spreadsheets.google.com/feeds/worksheets/1atRxZ4IgQPo5z5-DV7okHdtml8e3VdPjpuiEhwvU8FI/public/basic?alt=json
我意识到这意味着 Google 方面存在错误 - 但我不知道这是要修复的错误,还是需要更改 Tabletop 或已停止的服务的永久性更改完全访问 JSON 的选项。
有没有其他人遇到过这个问题并找到了解决方案?
【问题讨论】:
-
最近,我注意到当我访问公共电子表格的
https://spreadsheets.google.com/feeds/...时,返回Internal Error。我不确定这是否是暂时的情况。但我想这种情况可能和你一样。为了避免这种情况,我使用了以下端点。https://docs.google.com/spreadsheets/d/{fileId}/gviz/tq?gid={sheetId}&tqx=out:json和tqx=out:csv。但我认为在这种情况下,tabletop.js不能使用。因此需要解析检索到的值。很抱歉,在我的提议中,tabletop.js不能使用。
标签: google-sheets google-sheets-api tabletop.js