我的代碼只是簡單地將電子表格A中的數據添加到電子表格B.在電子表格A具有21行數據並且電子表格B只有20行的情況下,我的腳本顯然是試圖寫入電子表格中的一行B不存在。所以腳本顯然會自動添加50行以爲多餘的數據騰出空間。爲什麼Google腳本會自動添加50行?
有沒有辦法阻止它增加50行,當一行就足夠了?
這通常不會打擾我...但電子表格B格式化,它會自動複製下來50行。當電子表格B發佈到我們的網站時,這種格式不正確。
這是我的代碼。當rowCounterDTL
變量超過存在於電子表格乙行數,50行被自動添加到電子表格B.
//Cycle through each line item in the task log
for (var i = 0; i < dataTL.length; ++i) {
//If the package type is Other
if(dataTL[i][2] == "Other Item" && dataTL[i][4] == "Complete") {
continue;
} else if (dataTL[i][2] == "Other Item") {
rowCounterDTL = rowCounterDTL + 1
var daysOld = Math.round((todaysDate - dataTL[i][0])/1000/60/60/24);
sheetDTL.getRange(rowCounterDTL,1).setValue(dataTL[i][1]); //Add the client ID to column 1 of the DTL
sheetDTL.getRange(rowCounterDTL,2).setValue(dataTL[i][2]); //Add the package type to column 2 of the DTL
sheetDTL.getRange(rowCounterDTL,3).setValue(dataTL[i][3]); //Add the package notes to column 3 of the DTL
sheetDTL.getRange(rowCounterDTL,4).setValue(dataTL[i][4]); //Add the package priority to column 4 of the DTL
sheetDTL.getRange(rowCounterDTL,5).setValue(daysOld); //Add the age to column 5 of the DTL
if (daysOld>20){
sheetDTL.getRange(rowCounterDTL,6).setValue("On Hold?");
} else if(daysOld>7) {
sheetDTL.getRange(rowCounterDTL,6).setValue("Max!");
} else if (daysOld>4){
sheetDTL.getRange(rowCounterDTL,6).setValue("High");
} else if (daysOld>2){
sheetDTL.getRange(rowCounterDTL,6).setValue("Moderate");
} else if (daysOld<3){
sheetDTL.getRange(rowCounterDTL,6).setValue("Low");
}
sheetDTL.getRange(rowCounterDTL,1,1,6).setBackgroundRGB(255, 121, 255)
}
}
放一些代碼。也許我們可以幫助你。 – sircapsalot
補充,謝謝。 – user1569724
你的代碼中是否有這行代碼? 'for(var i = 0; i
sircapsalot