gpt4 book ai didi

javascript - Apps 脚本是否有等效的 Index(Match()) ?

转载 作者:行者123 更新时间:2023-12-03 02:42:44 25 4
gpt4 key购买 nike

首先:这里是 JS/Apps 脚本新手。 :)

我正在尝试用 Apps 脚本替换一些 Google 表格公式,并且想知道如何编写以下 if 语句:

var EMAIL_SENT = "EMAIL_SENT";

function onFormSubmitTest(e) {
//Open spreadsheet based on URL
var ss = SpreadsheetApp.openByUrl('sheetnamehere');
//Set as Active
SpreadsheetApp.setActiveSpreadsheet(ss);
//Set Tabs as Variables
var Rsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Emailer");
var Lsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Unique Databases");

//----Set last Rows as Variables----
// Gets Values from different sections, filters arrays to non-null values off of [0] index
var formResponses = Rsheet.getRange("N3:N").getValues().filter(function(row) {return row[0]}).sort();
var databaseNames = Lsheet.getRange("A2:B").getValues().filter(function(row) {return row[0]}).sort();
var developerNames = Lsheet.getRange("F2:F").getValues().filter(function(row) {return row[0]}).sort();

// Attempt finding current process owner's e-mail address

// Emailer Rows to Process
var startRow = 3; // First row of data to process. This is required because of various formatting messed up the opportunity for Last Row being the only row in the dataRange.

// Number of rows to process
var numRows = formResponses.length;

// Fetch the range of cells
var dataRange = Rsheet.getRange(startRow, 1, numRows, 30);

// Fetch values for each row in the Range.
var data = dataRange.getValues();

我试图加载到变量中的语句是 if var data [16] = var databaseNames [0], return var databaseNames [1]。我非常确定所有数组都已正确编码,以便按升序排序,以便更快地建立索引。

谢谢!

如果您能提供任何帮助/建议,我们将不胜感激。

最佳答案

我仍然不完全清楚,但我认为这可能就是您正在寻找的。在您的问题中,也许可以编辑它,给出数据结构和性质的具体示例。

var result = "";

var data = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32];
var databaseNames = [16,19];

var a = data[16]; // 16
var b = databaseNames[0]; //16

if(a === b){
result = a //16
}

关于javascript - Apps 脚本是否有等效的 Index(Match()) ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48252521/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com