Google Spreadsheet clearContent()函数错误

时间:2013-12-29 17:11:35

标签: google-apps-script google-sheets

谁能告诉我为什么这个功能不起作用?产生错误“无法在对象表中找到函数clearContent()”

function removeDuplicates() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  var newData = new Array();
  for(i in data){
    var row = data[i];
    var duplicate = false;
    for(j in newData){
      if(row[1] == newData[j][1] && row[2] == newData[j][2] && row[3] == newData[j][3] && row[6] == newData[j][6] && row[7] == newData[j][7] && row[8] == newData[j][8]){        
      duplicate = true;
      }
    }
    if(!duplicate){
      newData.push(row);
    }
  }
  sheet.clearContent();
  sheet.getRange(1, 1, newData.length, newData[4].length).setValues(newData);
};

提前致谢。

1 个答案:

答案 0 :(得分:1)

检查课程:SheetRange