简体   繁体   中英

index is out of bounds error

I am using google apps to write a simple form to push data to a google spreadsheet. I am not using any arrays, however I keep getting the error "Error encountered: Index (row 36, column 0) is out of bounds" From my research, seems like either an array is needed or it is expecting an array. I am confused because I ran this script before, but when I added more text fields, then I started getting this response. please help me, this is my first project using java with google, but i wasn't expecting this.

var ss = SpreadsheetApp.openById(SS_ID);
var employeesSheet = SpreadsheetApp.openById(SS_ID).getSheetByName('employees');


var location = ['NYC','LA'];
var title = ['Driver','Analyst','Detailer','Manager']


function doGet(e) {
  var app = UiApp.createApplication();
  var panel = app.createHorizontalPanel().setId('panel');
  var grid = app.createGrid(35,5).setId('grid');
  var grid2 = app.createGrid(5,5).setId('grid2'); // for map and summary

  // First Name 
var lblFirst = app.createLabel('First Name').setId('lblFirst');
var txtFirst = app.createTextBox().setId('txtFirst').setName('txtFirst');

  // Middle Initial 
var lblMiddle = app.createLabel('Middle Initial').setId('lblMiddle');
var txtMiddle = app.createTextBox().setId('txtMiddle').setName('txtMiddle');

// Last Name
var lblLast = app.createLabel('Last Name').setId('lblLast');
var txtLast = app.createTextBox().setId('txtLast').setName('txtLast');

// email
var lblEmail = app.createLabel('Email').setId('lblEmail');
var txtEmail = app.createTextBox().setId('txtEmail').setName('txtEmail');

//Title 
var lbltitle = app.createLabel('Title:').setId('lbltitle');
var lsttitle = app.createListBox().setId('lsttitle').setName('lsttitle')
                     .addItem('Driver')
                     .addItem('Analyst')
                     .addItem('Detailer')
                     .addItem('Manager');

A search on UiApp+createGrid leads me to Google Apps Script - Building a User Interface . Part of which states:

The grid size of 3 x 2 is defined in the instruction var mygrid = myapp.createGrid(3, 2); ..

Sounds like an array to me.


BTW - Agree with HFOE - this has nothing to do with Java.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM