Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/416.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在google电子表格中编写自定义函数,通过用户选项卡中的用户电子邮件查找用户_Javascript_Google Sheets - Fatal编程技术网

Javascript 在google电子表格中编写自定义函数,通过用户选项卡中的用户电子邮件查找用户

Javascript 在google电子表格中编写自定义函数,通过用户选项卡中的用户电子邮件查找用户,javascript,google-sheets,Javascript,Google Sheets,谢谢。我尽了最大努力但没有成功。请任何专家帮我。 在google电子表格中编写一个自定义函数,通过用户选项卡中的用户电子邮件查找用户。遵循以下步骤 自定义功能: function customFunctionName(arg1, arg2, ..., argN) { // The code for your custom function goes here ... // The value you return here will be displayed in the cell

谢谢。我尽了最大努力但没有成功。请任何专家帮我。 在google电子表格中编写一个自定义函数,通过用户选项卡中的用户电子邮件查找用户。

遵循以下步骤

自定义功能:

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

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

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

你能告诉我怎么叫吗。请详细告诉我我的意思是如何调用此函数?将其另存为google脚本。然后从打开它并从“运行”菜单中,应在spreedsheet上显示selectUsersCan I add interface ui图标作为总和符号。您需要为此添加一个附加项