Extending Google Apps-Spreadsheet using Google Apps Script
Google Apps Script is a JavaScript cloud scripting language to automate tasks. I gave a session on #GDGAhmedabad #DevFestAhm with 4 live demo of the application.
we are going to see. Google Apps Script is a JavaScript cloud scripting language to automate tasks ▸ Editor in a browser & managed in cloud (no install/setup, files stored,shared, versioned) ▸ JavaScript runtime in the cloud ( compliant, debuggable, and performant ) ▸ Set of APIs and hooks to Google products (extend and enhance, built in security, distribution mechanisms 2 11 Google apps, 1 platform in the cloud
https://script.google. com Google Drive > Create > More > Script ** ▸ Spreadsheet/App-bound script Tools >Script Editor ** ▸ Sites-bound script More > Manage Site > Apps Scripts > Add new script ** ** Do take care of the Authorization Step while scripting 3
Google Doc named 'DevFestAhm15 GAS Demo1' var doc = DocumentApp.create('DevFestAhm15 GAS Demo1'); // Access the body of the document, then add a paragraph. doc.getBody().appendParagraph('This document was created by Google Apps Script-Standalone Script. This is part of DevFestAhm15 GAS Demo1 provided by Dipali Vyas during the presentation in front of excellent participants of the session '); // Get the URL of the document. var url = doc.getUrl(); // Get the email address of the active user - that's you. var email = Session.getActiveUser().getEmail(); // Get the name of the document to use as an email subject line. var subject = doc.getName(); // Append a new string to the "url" variable to use as an email body. var body = 'Link to your doc created at DevFestAhm15 : ' + url; // Send yourself an email with a link to the document. GmailApp.sendEmail(email, subject, body); } ==========End 4
a few methods : ▸ getActiveSpreadsheet(), getActiveDocument(), and getActiveForm() allow bound scripts to refer to their parent file without referring to the file's ID. ▸ getUi lets bound scripts access the user interface for their parent file to add custom menus, dialogs, and sidebars. ▸ In Google Sheets, getActiveSheet(), getActiveRange(), and getActiveCell() let the script determine the user's current sheet, selected range of cells, or selected individual cell.setActiveSheet(sheet) and setActiveRange(range) let the script change those selections. ▸ In Google Docs, getCursor() and getSelection() let the script determine the position of the user's cursor or selected text. setCursor(position) and setSelection(range) let the script change those locations. 5
script resource that listens for a particular event and executes a function when that event fires. ▸ Simple triggers ▸ Specially-named built-in functions that are specific to spreadsheets ▹ onEdit ▹ onOpen ▹ onInstall ▸ Installable triggers ▸ Time-based triggers ▸ Container-bound installable triggers (let's make one!) 7
▸ Create quiz using Google Forms ▸ Automatically grades against answer key ▸ Can email results and answers to each student ▸ Provides charts to analyze the results 8
▸ Define a simple template using a draft email, document, sites page, or spreadsheet cell ▸ Add placeholder values that should be dynamically replaced ▸ Each spreadsheet row merged with template and sent out (Example of MailMerge by Amit Agrawal) 9
covering basic functionality 30+ tutorials with code Videos ▸ YouTube channels ▸ GoogleDevelopers and GoogleApps Stack Overflow Tag questions with google-apps-script ) ▸ Very active community, Google moderated Google Apps Developer Blog 10