Ich brauche ein wenig Hilfe beim Schreiben einer Google-Skript-Funktion. Ich habe ein Google-Blatt, in dem jeder einzelnen Zeile eine andere Farbe zugewiesen sein kann. Ich brauche ein Skript, das den HTML-Farbcode in der ersten Zelle jeder Zeile in dieser Zelle notieren kann.google script notice row colorGoogle Script Zeile Farbdetektor
Also sagen wir zum Beispiel Zeile 1 ist eine grüne Zeile und Zeile 2 ist eine blaue Zeile, die Zelle A1 sollte # 00ff00 sagen und A2 sollte # 0000ff nach dem Ausführen des Skripts sagen. Unten ist was ich bisher habe.
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();
}
}
Haben Sie erwogen, getbackgrounds (plural) und setValues zu verwenden? Auf diese Weise brauchen Sie keine Schleife. – utphx