我正在尝试在App脚本中运行循环,但是该脚本在第二次通过循环时会停止。
Google文档ID来自Google表格中的列表。我可以使其不循环运行,但是工作表范围一旦更新,就不会查看下一个ID。谁能看到哪里出了问题?
function myFunction() {
var ss = Spreadsheetapp.openById('1LETEuEdYxyIxQtQgFWTwm3GgZWDAR5ehUUEIh_jN7zA');
var sheet = ss.getSheetByName('Sheet1');
var lr = sheet.getRange(2,5).getDataRegion(Spreadsheetapp.Dimension.ROWS).getLastRow();
for(var i=0; i<lr+1; i++) {
var id = sheet.getRange(i+2,5,1,1).getvalue();
var doc = DocumentApp.getactiveDocument();
var docInside = DocumentApp.openById(id).getBody();
var text = docInside.getTables();
var table = text[3].getNumRows();
var val = text[3].getRow(2).getText();
var pasteArea = doc.editAsText();
pasteArea.appendText(val);
var text = docInside.getTables();
var loops = text[7].getNumRows();
for(var i=0; i<loops-5; j++) {
var val = text[7].getRow(j+5).getText();
var pasteArea = doc.editAsText();
pasteArea.appendText(val);
}
}
};