我在第11行和第13行都有错误
如何解决误差
function sheetUpdate(props) {
var ss = SpreadsheetApp.openById('1cqhYHx-M54x-ZRmKLIdQo9DZ0jl-li-THy3w-wGf4UA');
var sheet = ss.getSheetByName("Master Rent Info 7-25-22");
var range = sheet.getRange("A2:A");
var cell = range.createTextFinder("props.Unit ID").matchEntireCell(true).matchCase(true).findNext();
console.log(cell)
var range1 = sheet.getRange("1:1");
var cell1 = range1.createTextFinder("props.field").matchEntireCell(true).matchCase(true).findNext();
console.log(cell1)
var colnum = cell1.getColumn();
console.log(colnum)
var rownum = cell.getRow();
console.log(rownum)
sheet.getRange(rownum,colnum).setValues(props.val)
}
发布于 2022-11-30 11:21:57
来自文档
返回
Range
-下一个匹配单元格,如果没有以前的匹配,则返回null。
您应该检查搜索是否成功,如下所示:
const cell = range.createTextFinder(props['Unit ID').matchEntireCell(true).matchCase(true).findNext();
if (!cell) {
console.log(`Could not find any cells with the value "${props['Unit ID'}".`);
} else {
console.log(`Found cell at ${cell.getA1Notation()}.`)
}
https://stackoverflow.com/questions/74626759
复制相似问题