配列に値が存在するかどうかを調べる方法がわかりません。私はこれが単純であるべきだと思ったが、そこには行けなかった。Google Appsスクリプトは配列内の値を見つけます
私はこのコードを持っている:
function findPlayer() {
//This section gets the values from the first row of all the columns
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Players");
var lastColumn = ss.getLastColumn()
var playerNameRow = ss.getRange(1, 2, 1, lastColumn - 3);
var playerNameValues = playerNameRow.getValues();
//This just sets the value we're looking for (which in this example is in the 7th Column "G"). And logs the Array, just to check it.
var findPlayer = "Dan";
Logger.log(playerNameValues)
//and here we just loop through the playerNameValues array looking for the findPlayer value
for(var n in playerNameValues){
if(playerNameValues[n][0]== findPlayer) {break}
}
//and here, if the above search does find the matching value it should log it
Logger.log(n);
}
playerNameValueが正しくログインされている何が起こっているのが、nは常に、それはむしろ列7よりも、それはチェックの最初の項目の値を見つけることだ意味を0としてログインしています値はどこにありますか。
(https://developers.google.com/apps-script/articles/mail_merge)[メールチュートリアルをマージ]、特に完全なコードでは一部に注意を払う、この上のサンプルコードを見てみましょうgetRowsData()関数からセクションを削除します。データをオブジェクトに読み込む方法です。 playNameValues.player [n]を使用するか、ヘッダー行に表示されているものを使用できます。 –