Google电子表格脚本:检查单元格是否为空 [英] Google Spreadheets Scripts: check if cell is empty
本文介绍了Google电子表格脚本:检查单元格是否为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在单元格为空的情况下在单元格中输入变量。 if语句不起作用。任何建议?
I want to input a variable in a cell only if the cell is empty. The if statement, however, does not work. Any advice?
var ss=SpreadsheetApp.getActiveSpreadsheet();
var r=ss.getRange("'odpovědi'!A2:J");
var rws=r.getNumRows();
ax=r.getCell(rws-1, 10).getValue();
if (ax == "") {
ax = "foo";
r.getCell(rws-1, 9).setValue(ax);
}
推荐答案
无需提取值以确定单元格是否为空。 Google Spreadsheet API已经有一个方法:范围 - isBlank方法
No need to extact the value to determine if the cell is empty. Google Spreadsheet API already has a method for this: Range - isBlank method
var cell = r.getCell(rws-1, 10);
if (cell.isBlank()) {
cell.setValue("foo");
}
这篇关于Google电子表格脚本:检查单元格是否为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文