Google 脚本:组合多个函数并在同一行输出(单元格+ [1] [2] 等)

Google Scripts: Combining multiple functions and output on same row (cell+ [1] [2], etc)

我在 Google 脚本中使用以下公式时遇到一些困难。我想要实现的是:

1- 从 A1 获取数字

2-从Number,有多个returns

3- 在相邻单元格 (A2, A3) 中将那些 return 设置在与原始数字相同的行 (A) 中

现在的样子:

function GETALLTWO(bid) {
  if (input.map) {     
    return input.map(GETALLTWO)
  } else {
    return input;
  }
  var api_str = "client_id=randomstringofnumbers&client_secret=anotherrandomstringofnumbers";
  var url= "https://api.untappd.com/v4/beer/info/" + bid + "?" + api_str;
  var response = UrlFetchApp.fetch(url);
  if (response.getResponseCode() == 200) {
    var respObj = JSON.parse(response.getContentText());
    var beer = respObj.response.beer;
    if (beer.bid == bid) {
      return beer.beer_name;
      return beer.rating_score;
      return beer.stats.total_user_count;
      return beer.rating_count;
      return beer.stats.monthly_count;
      return beer.created_at;
    }
  }
}

从 Code.gs 开始,我可以让第一个 Return 工作,但我是否正确组合了不同的功能?我如何将位置设置为 return?

希望有人能提供帮助,很想了解有关脚本的更多信息。

// 编辑以备将来参考:

function getAll(bid) {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getSheetByName('Overview')
  var row=sh.getActiveCell().getRow();
  var bid=sh.getRange(row,3).getValue();
  var api_str =     "client_id=randomstring&client_secret=randomstring";
  var url= "https://api.untappd.com/v4/beer/info/" + bid + "?" +     api_str;
  var response = UrlFetchApp.fetch(url);
  if (response.getResponseCode() == 200) {
    var respObj = JSON.parse(response.getContentText());
    var beer = respObj.response.beer;
    if (beer.bid == bid) {
      var rObj= {name:beer.beer_name,rating:beer.rating_score,totalcount:beer.stats.total_user_count,ratingcount:beer.rating_count,monthlycount:beer.stats.monthly_count,createddate:beer.created_at};
      values=[[rObj.name,rObj.ratingcount,rObj.rating,rObj.totalcount,rObj.monthlycount,rObj.createddate]];
      return values;
    }
  }
}

使用此功能,您只需将光标放在要从中获取出价的行上。它会将数据放回从 D

列开始的那一行
function getAllTwo() {
  var ss=SpreadsheetApp.getActive();
  var sh=ss.getSheetByName('Your Sheet Name')
  var row=sh.getActiveCell().getRow();
  var bid=sh.getRange(row,3).getValue();
  var api_str = "client_id=randomstringofnumbers&client_secret=anotherrandomstringofnumbers";
  var url= "https://api.untappd.com/v4/beer/info/" + bid + "?" + api_str;
  var response = UrlFetchApp.fetch(url);
  if (response.getResponseCode() == 200) {
    var respObj = JSON.parse(response.getContentText());
    var beer = respObj.response.beer;
    if (beer.bid == bid) {
      var rObj= {name:beer.beer_name,rating:beer.rating_score,totalcount:beer.stats.total_user_count,ratingcount:beer.rating_count,monthlycount:beer.stats.monthly_count,createdate:beer.created_at};
      values=[[rObj.name,rObj.ratingcount,rObj.rating,rObj.totalcount,rObj.monthlycount,rObj.createddate]];
      sh.getRange(row,4,values.length,values[0].length).setValues(values);
    }
  }
}