UI 웹 앱 배포. 배포 스크립트 URL을 보려고 후 "널 (null)의"getSheets "방법을 호출 할 수 없습니다"형식 오류를 얻기 :GAS에 UI 웹 앱을 처음 배포 할 때
https://docs.google.com/spreadsheet/ccc?key=0AnJTymuE8awLdHZ6QzhNVXpjeFphM3pMV1cxU0daZ2c
스크립트 코드 :
다음https://script.google.com/macros/s/AKfycbzuQNbkTeBpRPz75Q4dRiVLfEYtuLiuBKnWeA5CbD0/dev
하면 스프레드 시트의
// https://developers.google.com/apps-script/class_listbox - How to create listBox
function doGet() {
//var ss = SpreadsheetApp.openById("0AnJTymuE8awLdHZ6QzhNVXpjeFphM3pMV1cxU0daZ2c");
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[1];
var app = UiApp.createApplication().setTitle('App to show how ListBox data can update');
var panel = app.createVerticalPanel();
var lb = app.createListBox(true).setId('myLBid').setName('myLBname');
// how many items to show
lb.setVisibleItemCount(10);
// get sorted names
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
var values = rows.getValues();
for (var i = 0; i <= numRows - 1; i++) {
var row = values[i];
lb.addItem(row);
}
panel.add(lb);
var button = app.createButton('Submit');
var handler = app.createServerClickHandler('respondToSubmit').addCallbackElement(panel);
button.addClickHandler(handler);
panel.add(button);
app.add(panel);
ss.show(app);
}
// http://youtu.be/5VmEPo6Rkq4 - How to have sumbit write data to ss
function respondToSubmit(e) {
var app = SpreadsheetApp.getActiveSpreadsheet();
//reference widget name to capture what user selected
var listBoxValue = e.parameter.myLBname;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[2];
var lastRow = sheet.getLastRow()+1;
var lastCell = sheet.getRange("A"+lastRow);
lastCell.setValue(listBoxValue);
return app.close();
}
/**
* Adds a custom menu to the active spreadsheet, containing a single menu item
* for invoking the readRows() function specified above.
* The onOpen() function, when defined, is automatically invoked whenever the
* spreadsheet is opened.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function onOpen() {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var entries = [{
name : "Names",
functionName : "doGet"
}];
sheet.addMenu("Script Menu", entries);
};
편집기에서 실행하면 완벽하게 작동합니다.
웹 앱이 작동하도록 코드에서 수정해야 할 부분을 찾고 싶습니다. ss 내부에서 실행될 때처럼 스크립트 URL에 UI가 나타날 것으로 기대합니다. 그게 무슨 일이 아니야?
내가 왜 openById를 사용했는지, 왜 내가 댓글을 남겼는지 확신 할 수 없습니다. 나는 'return app;'이 필요하다는 것을 놓쳤다. 문서에서. 감사합니다. http://goo.gl/FTIKB –