javascript - 如何在 google app 脚本中获取我的 google sheet 的 json 格式?
问题描述
我正在尝试获取我的谷歌表格的 json 格式。我尝试了很多教程,但它不起作用。
解决方案
这个怎么样:
function shjsn() {
const ss=SpreadsheetApp.getActive();
const sh=ss.getSheetByName('SheetName');
const vs=sh.getDataRange().getValues();
return JSON.stringify(vs);
}
或者也许对于整个电子表格:
function ssjsn() {
const ss=SpreadsheetApp.getActive();
const shts=ss.getSheets();
let vs=[];
shts.forEach(function(sh,i){vs.push(sh.getDataRange().getValues());});
return JSON.stringify(vs);
}
推荐阅读
- json - 使用 Swift 解码多层嵌套 JSON
- asp.net-mvc - 十进制数据字段引发验证错误(ASP.Net MVC)
- java - 如何在循环中堆叠计算结果
- php - 读取 mysql 表的 JSON 响应无效
- go - 如何找到 geth.ipc 路径以打开新提示?
- python - 从另一个 Python 脚本更改 Python 脚本参数
- javascript - 文件名中带逗号的文件正在 Firefox 中下载,但在 Chrome 中没有
- spring - 无法更改配置“:实现”的依赖关系后,它已包含在依赖关系解析中
- java - 为什么在 onCreateView() 中调用 Fragment?
- javascript - 导入 webpack 包会抛出 module.default 不是函数