2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | <-- /* * This script was used in the video tutorial * Learn how to create UI in Apps Script * */ function showDialog() { // create a new application var app = UiApp.createApplication(); app.setTitle("My Application"); // create panels, text boxes and widgets var panel = app.createVerticalPanel(); var textBox = app.createTextBox(); textBox.setName('myTextBox').setId('myTextBox'); var button = app.createButton('Submit'); // add widgets to panels panel.add(textBox); panel.add(button); // create handler to respond to events var clickHandler = app.createServerClickHandler("respondToSubmit"); button.addClickHandler(clickHandler); clickHandler.addCallbackElement(panel); // assemble everything in app app.add(panel); var doc = SpreadsheetApp.getActive(); // show the app doc.show(app); } // this function responds to submit button function respondToSubmit(e) { var app = UiApp.getActiveApplication(); // get the value of the text box var textBoxValue = e.parameter.myTextBox; // put data into the spreadsheet var sheet = SpreadsheetApp.getActiveSheet(); var lastRow = sheet.getLastRow()+1; var lastCell = sheet.getRange("A"+lastRow); lastCell.setValue(textBoxValue); // close the dialog box return app.close(); } --> |
Tuesday, August 7, 2012
Google Apps Script – Building a Simple GUI
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment