我正在尝试这个脚本来创建数据验证,但它总是不起作用
function test_validation()
{
var Spread = SpreadsheetApp.getActiveSpreadsheet();
var Sheet = Spread.getSheetByName('Sheet1');
var validate1 = Sheet.getRange("A1").getDataValidation();
Logger.log(validate1.getCriteria());
Logger.log(validate1.getCriteriaValues());
var option = new Array();
option[0]="true";
option[1]="1";
option[2]="2";
option[3]="3";
var criteria="ITEM_IN_LIST";
var helpText="Test Help Text"
var Combobox = Sheet.getRange("A2").getDataValidation();
//The line below display error
//"Cannot find method (class)setCriteria(string,String[]). "
Combobox.setCriteria(criteria,option);
Combobox.setHelpText(helpText);
var validate2 = Sheet.getRange("A2").setDataValidation(Combobox);
Logger.log(Sheet.getRange("A2").getDataValidation().getCriteria());
Logger.log(Sheet.getRange("A2").getDataValidation().getCriteriaValues());
}
提前致谢。