[Google Apps Script] onOpen Event
페이지 정보
본문
function onOpen(event) {
var ss = event.source;
var menuEntries = [];
menuEntries.push({name: "Go to sheet...", functionName: "showGoToSheet"});
ss.addMenu("Tasks", menuEntries);
}
// Google 스프레드 시트의 특정 시트에 연결
function onOpen(event) {
var ss = event.source;
var menuEntries = [];
menuEntries.push({name: "Go to sheet...", functionName: "showGoToSheet"});
ss.addMenu("Tasks", menuEntries);
}
function showGoToSheet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var allsheets = ss.getSheets();
var app = UiApp.createApplication();
app.setTitle("Go to sheet...").setWidth(800).setHeight(600);
var table = app.createFlexTable();
table.setCellPadding(5).setCellSpacing(0);
var goToSheetClick = app.createServerHandler('handleGoToSheetClick');
var widgets = [];
for (var i = 0; i < allsheets.length; i++) {
var sheet_name = allsheets[i].getName();
widgets[i] = app.createHTML(sheet_name).setId(sheet_name).addClickHandler(goToSheetClick);
table.setWidget(i, 1, widgets[i])
}
var panel = app.createSimplePanel();
panel.add(table);
app.add(panel);
ss.show(app);
}
function handleGoToSheetClick(e) {
var sheet_name = e.parameter.source;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(sheet_name);
sheet.activate();
var app = UiApp.getActiveApplication();
app.close();
return app;
}
// 버튼을 클릭하고 "Sheet5"로 이동
function showSheetByName(Name) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName(Name);
SpreadsheetApp.setActiveSheet(sheet);
}
function showSheet5() {
showSheetByName("Sheet5");
}
추천0 비추천0
댓글목록
등록된 댓글이 없습니다.