第1页
if let featured = dict["featured"] as? String {
print("Success")
}
else {
print("Failure")
}
由于这是一张google工作表,我试图运行以下脚本来删除与Name和Date Columns匹配的行。例如。 Laura在01AUG的同一天有2个条目。因此,我希望删除这两行。我正在尝试以下脚本,但它不起作用。
Timestamp |Name | Shift.....| Date....| Letter..|
19/05/2016 15:44:46|Mark | Swap | 02/AUG | S |
Timestamp2 |Ivon | Give away | 25/ AUG | G |
Timestamp3 |Laura| Take | 01/AUG | A |
Timestamp4 |Ann | Take | 02/AUG | A |
Timestamp5 |Ann | Give away | 03/AUG | G |
Timestamp6 |Laura| Delete | 01/AUG | D |
答案 0 :(得分:0)
V4。最后(我想)。
如果Cx是"删除"或"删除"删除行x和行,其中B和D与行x' s相同。
function objTst(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName("Form responses 2");
var megarng = sheet.getRange(2, 2, sheet.getLastRow(),sheet.getLastColumn()).getValues(); //[][]
var rodel = [0]; //rows to delete
for (i = 0; i<megarng.length; i++){
if (String(megarng[i][1])==("Delete"||"delete")){ //megarng[][x] 0=b, 1=c, 2=d
rodel.push(i+2)
for (g=0; g<megarng.length ; g++){
if(String(megarng[g][0])===String(megarng[i][0]) && String(megarng[g][2])===String(megarng[i][2])){
rodel.push(g+2);
Logger.log(megarng[g][0]);
Logger.log(megarng[i][0]);
Logger.log(megarng[g][2]);
Logger.log(megarng[i][2]);
Logger.log(i+"i");
Logger.log(g);
}
}
}
rodel.sort(function comp(a,b){return a-b});
Logger.log(rodel);
}
for (i=rodel.length-1 ; 0<i; i--){if (rodel[i-1]!==rodel[i]){sheet.deleteRow(rodel[i]);}}
}