Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.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
Google apps script 如何从用于循环计算的Google Apps脚本中排除某些列_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 如何从用于循环计算的Google Apps脚本中排除某些列

Google apps script 如何从用于循环计算的Google Apps脚本中排除某些列,google-apps-script,google-sheets,Google Apps Script,Google Sheets,作为谷歌应用程序脚本的一部分,我正在通过列值进行循环,并将数据存储在它们的位置。我想从该操作中排除某些行,因为我不想覆盖这些列中的数据 // save back the values from the editor sheet to the master data sheet var lookUpTable = ss.getRangeByName("Editor_sheet_template!z_saveback_LookupTableOfCellsAndColumnsToSave"); var

作为谷歌应用程序脚本的一部分,我正在通过列值进行循环,并将数据存储在它们的位置。我想从该操作中排除某些行,因为我不想覆盖这些列中的数据

// save back the values from the editor sheet to the master data sheet
var lookUpTable = ss.getRangeByName("Editor_sheet_template!z_saveback_LookupTableOfCellsAndColumnsToSave");
var sourceCellAddress, sourceCellValue, targetCell, targetCellColumn;
// iterate through all rows in the lookup table
for (var cellRow = 1; cellRow <= lookUpTable.getHeight(); cellRow++) {
  // save the value of the editor sheet cell listed in the lookup table to its
  // corresponding column on the master data sheet
  sourceCellAddress = lookUpTable.getCell(cellRow, /* column */ 1).getValue();
  sourceCellValue = editorSheet.getRange(sourceCellAddress).getValue();
  targetCellColumn = lookUpTable.getCell(cellRow, /* column */ 2).getValue();
  if(targetCellColumn != 'A','D','E'){
    Logger.log(targetCellColumn);
    targetCell = masterDataSheet.getRange(targetCellRow, targetCellColumn);
    targetCell.setValue(sourceCellValue);
  }  
}    
//将值从编辑器工作表保存回主数据表
var lookUpTable=ss.getRangeByName(“编辑器\u工作表\u模板!z\u保存\u lookuptableofcells和columnstosave”);
变量sourceCellAddress、sourceCellValue、targetCell、targetCellColumn;
//遍历查找表中的所有行

对于(var cellRow=1;cellRow,您不需要获取单元格的值,而是需要获取A1表示法并使用substring方法获取字母。然后,检查列A、D或E的“if”条件应该可以工作

// save back the values from the editor sheet to the master data sheet
var lookUpTable = ss.getRangeByName("Editor_sheet_template!z_saveback_LookupTableOfCellsAndColumnsToSave");
var sourceCellAddress, sourceCellValue, targetCell, targetCellColumn;
// iterate through all rows in the lookup table
for (var cellRow = 1; cellRow <= lookUpTable.getHeight(); cellRow++) {
  // save the value of the editor sheet cell listed in the lookup table to its
  // corresponding column on the master data sheet
  sourceCellAddress = lookUpTable.getCell(cellRow, /* column */ 1).getValue();
  sourceCellValue = editorSheet.getRange(sourceCellAddress).getValue();
  targetCellColumn = lookUpTable.getCell(cellRow, /* column */ 2)
    .getA1Notation().substring(0, 1); //this gets the first character of the A1 Notation which is the column letter
  if(targetCellColumn != 'A','D','E'){
    Logger.log(targetCellColumn);
    targetCell = masterDataSheet.getRange(targetCellRow, targetCellColumn);
    targetCell.setValue(sourceCellValue);
  }  
}  
//将值从编辑器工作表保存回主数据表
var lookUpTable=ss.getRangeByName(“编辑器\u工作表\u模板!z\u保存\u lookuptableofcells和columnstosave”);
变量sourceCellAddress、sourceCellValue、targetCell、targetCellColumn;
//遍历查找表中的所有行
对于(变量cellRow=1;cellRow