【问题标题】:How can I get the json format of my google sheet in google app script?如何在 google app 脚本中获取我的 google sheet 的 json 格式?
【发布时间】:2020-06-28 15:04:23
【问题描述】:

我正在尝试获取我的谷歌表格的 json 格式。我尝试了很多教程,但都不起作用。

【问题讨论】:

  • “我的 google sheet 的 json 格式”是什么意思?另请按照How to Ask 中的建议添加您的搜索/研究工作的简要说明。

标签: javascript json google-apps-script google-sheets google-sheets-api


【解决方案1】:

这个怎么样:

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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-17
    • 2019-01-02
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 2023-01-07
    • 2021-07-14
    • 1970-01-01
    相关资源
    最近更新 更多