App Script for Google Docs
My latest programming project lead me to write a Google Apps Script (GAS). The first thing I will say about GAS is that the documentation is a little rough, but if you stick with it, you can build some powerful add-ons to Google Docs and Sheets. To start building a GAS, open a new Google Doc or Sheet and select
Script editor.... This will launch a light development environment where you can write, test, and debug your GAS.
A few caveats that I should mention before you get started:
- Collaboratively working on GAS is a nightmare, there is no built-in support for doing distributed work with multiple people
- GAS have different types of deployment models… in this post, I am referring exclusively to GAS that are add-ons
- While you are building an add-on it is coupled directly with either an individual Doc or Sheet; once you deploy an add-on it can be connected to many documents
- The GAS editor allows you test server-side functionality directly (this is a really feature!)
With that out of the way, you can get down to business. The “add-on architecture” is typically separated into two parts: (1) client-side code and (2) server-side code.
The server-side code is where you have the ability to modify the contents of the Google Doc (or Sheet).