Google apps script 谷歌电子表格脚本中的停止条件

Google apps script 谷歌电子表格脚本中的停止条件,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我使用以下代码创建一个列表框,其中包含来自电子表格的信息: function Selectbox(NameBox ,Row ,ID ,NameSheet ,NameCol) { var sheet = SpreadsheetApp.openById(ID).getSheetByName(NameSheet); var lastRow = sheet.getLastRow(); var app = UiApp.getActiveApplication(); var ListBox

我使用以下代码创建一个列表框,其中包含来自电子表格的信息:

function Selectbox(NameBox ,Row ,ID ,NameSheet ,NameCol) {
  var sheet = SpreadsheetApp.openById(ID).getSheetByName(NameSheet);
  var lastRow = sheet.getLastRow();
  var app = UiApp.getActiveApplication();
  var ListBox = app.createListBox().setWidth(125).setName(NameBox);
  var ind = getColIndexByNamelink(NameCol, sheet);
  ListBox.setVisibleItemCount(1);
  for (var i = 2; i < lastRow + 1; i++) {
    var Item = sheet.getRange(i, (ind * 1)).getValue();
    if (Item == ' ')
      break;
    else
    ListBox.addItem(Item);
  }
  var grid = app.getElementById('grid');
  grid.setWidget(Row, 1, ListBox);
  return app;
}
函数选择框(名称框、行、ID、名称表、名称列){
var sheet=SpreadsheetApp.openById(ID).getSheetByName(NameSheet);
var lastRow=sheet.getLastRow();
var app=UiApp.getActiveApplication();
var ListBox=app.createListBox().setWidth(125).setName(NameBox);
var ind=getColIndexByNamelink(名称、表格);
ListBox.setVisibleItemCount(1);
对于(变量i=2;i
在带有“if(item=''”的行中,当电子表格中的单元格为空时,我应该使用什么标准来停止循环


谢谢

我倾向于使用我的库的以下函数来检查变量(字符串)是否为空(如果这是您的意思)


在代码中,引号之间有一个空格。这不是空字符串。酷!“有人这样做过吗!”翻译?谢谢,这很有用
 function isNotEmpty(string) 
{

    if(!string)             return false;         
    if(string == '')        return false;
    if(string === false)    return false; 
    if(string === null)     return false; 
    if(string == undefined) return false;
    string = string+' '; // check for a bunch of whitespace
    if('' == (string.replace(/^\s\s*/, '').replace(/\s\s*$/, ''))) return false;       
    return true;        
}