写入以在Google电子表格中制​​作自定义功能,以便在用户标签中通过用户电子邮件查找用户

时间:2014-04-02 09:33:17

标签: javascript google-sheets

提前致谢。我尽我所能但没有成功。请任何专家都能帮助我。 在Google电子表格中编写自定义功能,以便在用户标签中通过用户电子邮件查找用户。

2 个答案:

答案 0 :(得分:0)

关注Google Developers Official Link

自定义功能:

function customFunctionName(arg1, arg2, ..., argN) {
  // The code for your custom function goes here
  ...
  // The value you return here will be displayed in the cell in the Spreadsheet
  // in which the custom function is entered
  return someValue;
}

答案 1 :(得分:0)

这在很大程度上取决于工作表的结构,以此为例:

function selectUsers() {
  var spreadsheet = SpreadsheetApp.openById('YOURFILEID');
  var name = spreadsheet.getName();
  Logger.log('spread name '+name);
  var usersSheet = spreadsheet.getSheetByName('Users');
  name = usersSheet.getName();
  Logger.log('usersSheet name '+name);
  var rows = usersSheet.getRange(3,3, 15, 5);//depends on the actual size of your data
  var numRows = rows.getNumRows();
  Logger.log('numRows ' + numRows);
  var emails = [];
  var values = rows.getValues();
  for (var row in values) {
    var email = values[row][1];//depends on which column you used for email, this example the 2nd.
    emails.push(email);
  }
}