Мне нужно немного помочь написать функцию скрипта google. У меня есть лист Google, в котором каждая отдельная строка может иметь другой цвет, назначенный ему. Мне нужен скрипт, который может отметить код цвета html, найденный в первой ячейке каждой строки в этой ячейке.google script note row colorGoogle Script color color detector
Так, например, скажем, строка 1 - это зеленая строка, а строка 2 - синяя строка, ячейка A1 должна сказать # 00ff00, а A2 должен сказать # 0000ff после запуска скрипта. Ниже я до сих пор.
function colorDetector() {
var startRow = 1; // First row of data to process
var numRows = 3; // Number of rows to process
var currentsheet = 'Production' // What sheet you would like to process (must be within ' ')
//This section prepares the document to be read
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName(currentsheet);
var dataRange = sheet.getRange(startRow, 1, numRows, 15) // Fetch values for each row in the Range (row, column, numRows, numColumns)
var data = dataRange.getValues();
for (var i = 0; i < data.length; ++i) {
var row = data[i];
//this is the section i cant seem to get working correctly
var color = row[0].getbackground(); //should set the variable "color" to the html color found in the first cell of the current row.
sheet.getRange(startRow + i, 1).setValue(color); // notes the variable found
SpreadsheetApp.flush();
}
}
Считаете ли вы использование getbackgrounds (множественное число) и setValues? Таким образом, вам не нужен цикл «для». – utphx