我已经创建了这个脚本,它制作了一个发布简介的表单,我希望它被提交到电子表格,但Exception: incorrect range width, was 3 but should be 5
无论我如何更改 getRange 中的行数,我都会收到这个错误,这个错误中的数字总是相同的。有什么方法可以更新我不知道的代码吗?每次更改代码时我都会部署代码。
function doGet() {
var app = UiApp.createApplication().setTitle('Form for news update');
//panel for form
var panel = app.createVerticalPanel().setId('panel');
//elements for the form
var postTitle = app.createLabel('Title');
var title = app.createTextBox().setId('title');
var postLabel = app.createLabel('new post:');
var post = app.createTextArea().setId('post');
var btn = app.createButton('Submit');
//handler to execute posting by click the button
var handler = app.createServerClickHandler('Submit');
handler.addCallbackElement(panel);
//add this handler to the button
btn.addClickHandler(handler);
//add the elements to the panel
panel.add(postTitle)
.add(title)
.add(postLabel)
.add(post)
.add(btn);
//add the panel to the app
app.add(panel);
return app;
}
function Submit(e){
//get the app and send it to the spreadsheet
var app = UiApp.getActiveApplication();
try{
//get the post
var postTitle = e.parameter.postTitle;
var title = e.parameter.title;
var post = e.parameter.post;
//put the info into a spreadsheet
var ss = SpreadsheetApp.openById('KEY IN HERE REMOVED FOR PRIVACY');
var sheet = ss.getSheets()[0];
sheet.getRange(sheet.getLastRow()+1, 1).setValues([[ title, post]]);
}catch(e){
app.add(app.createLabel('Error occured:'+e));
return app;
}
}