Sunday, 25 August 2013
Undefined error on google spreadsheet script
Undefined error on google spreadsheet script References I am desperately looking for some help about an error I keep getting when running a function on a Google Spreadsheet. I have written all the code and I get two situations: if I run the script from the sheet where it is supposed to work, I get the error \"Oops We\'re sorry. The server encountered an error. Please press \"OK\" to refresh the sheet\" even though all the operations are actually completed below the error popup. if I run the script from another sheet the script is completed successfully. I thought this problem could have been related to the active sheet function, so I started debugging to find a solution. I noticed I get absolutely no problems with all of the code except a part in which I ask the spreadsheet to make some operations on the columns: first to create a new one, then to resize two of them and eventually to delete one. I am attaching all the code so that you can get a better idea of what the script is doing. Thank you for your attention. Tony function forecastSettimanale() { var ss = SpreadsheetApp.getActiveSpreadsheet(); var sheet = ss.getSheets()[0]; var data = sheet.getDataRange(); // I need to operate on a column that has TOT written on its top, and its // position can vary var k = 1; while (k <= data.getNumColumns()) { var startRange = sheet.getRange(1, k, 1); var value = startRange.getValue(); if(value == \'TOT\') { var flagColumn = startRange.getColumn(); // } k++; } sheet.insertColumnsBefore(flagColumn, 1); sheet.setColumnWidth(flagColumn - 1, 40); sheet.setColumnWidth(flagColumn, 50); sheet.deleteColumn(flagColumn - 6); sheet.setColumnWidth(flagColumn, 100); }
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment