Google Sheets Programming With Google Apps Script (2015 Revision Complete)

Retired

This book is no longer available for sale.

Google Sheets Programming With Google Apps Script (2015 Revision Complete)

Your Guide To Building Spreadsheet Applications In The Cloud

About the Book

All those who buy this version and those who have bought it already will get future updates and additions for free (2015 revision is complete).

Google Spreadsheets and Google Apps Scripts (GAS) are both evolving rapidly so I want to ensure that the material presented here remains up-to-date and continues to improve.  Please email me details of any errors you find or with any suggestions you have for new material.

This book provides a resource for all those wishing to develop spreadsheet applications in Google Spreadsheets. The book grew out of a blog that I have been writing since early 2011 see blog site. However, it aims to be much more comprehensive than the blog. The blog gave me a good idea of what material is of most interest to readers, thereby allowing me to concentrate on these topics. It covers the Google Apps Script sub-set of JavaScript as it applies to Google Spreadsheets. As the reader progresses through the book, they will learn how to:

  • Write user-defined spreadsheet functions.
  • Manipulate the key Google API objects.
  • Build user interfaces.
  • Interact with other Google applications and services.
  • Use a MySQL database running in the Cloud as a back-end data store.

Throughout there is an emphasis on practical applications.

It provides well documented code examples that can be cut-and-pasted and then modified to suit the reader's needs.

There is also an appendix for experienced Excel VBA users that shows common spreadsheet coding techniques in both VBA and Google Apps Script.

All the example code in this book is available for download as a single file at https://github.com/Rotifer/GoogleSpreadsheetProgramming_2015

Please send any feedback/queries/correction/requests for clarification to:

mick@javascript-spreadsheet-programming.com

About the Author

Michael Maguire
Michael Maguire

I am a data manager. I used Excel VBA extensively in the past and wrote this book after learning how to program Google Spreadsheets with Google Apps Script.

Table of Contents

  • Chapter 1: Introduction
    • 1.1 Google Sheets
    • 1.2 Google Apps Script (GAS)
    • 1.3 JavaScript or Google Apps Script?
    • 1.4 Summary Of Topics Covered
    • 1.5 Software Requirements For This Book
    • 1.6 Intended Readership
    • 1.7 Book Code Available On GitHub
    • 1.8 My Blog On Google Spreadsheet Programming
    • 1.8 Guideline On Using This Book
    • 1.9 2015 Update Notes
  • Chapter 2: Getting Started
    • 2.1 Introduction
    • 2.2 Google Apps Script Examples
    • 2.2 Executing Code – One Function At A Time
    • 2.3 Summary
  • Chapter 3: User-Defined Functions
    • 3.1 Introduction
    • 3.2 Built-in Versus User-Defined Functions
    • 3.3 Why Write User-Defined Functions
    • 3.4 What User-Defined Functions Cannot Do
    • 3.5 Introducing JavaScript Functions
    • 3.6 User-Defined Functions Versus JavaScript Functions
    • 3.7 Using JSDoc To Document Functions
    • 3.8 Checking Input And Throwing Errors
    • 3.9 Encapsulating A Complex Calculation
    • 3.10 Numeric Calculations
    • 3.11 Date Functions
    • 3.12 Text Functions
    • 3.13 Using JavaScript Built-In Object Methods
    • 3.14 Using A Function Callback
    • 3.15 Extracting Useful Information About The Spreadsheet
    • 3.16 Using Google Services
    • 3.18 Summary
  • Chapter 4: Spreadsheets and Sheets
    • 4.1 A Note On Nomenclature
    • 4.2 Native And Host Objects
    • 4.3 A Note On Method Overloading In Google Apps Script
    • 4.5 Object Hierarchies
    • 4.6 SpreadsheetApp
    • 4.7 The Spreadsheet Object
    • 4.8 The Sheet Object
    • 4.9 Practical Examples Using Spreadsheet And Sheet Objects
    • 4.10 Summary
  • Chapter 5: The Range Object
    • 5.1 Introduction
    • 5.2 Range Objects Are Complex
    • 5.3 Creating A Range Object
    • 5.4 Getting And Setting Range Properties
    • 5.5 The Range offset() Method
    • 5.6 The Sheet Data Range
    • 5.7 Transferring Values Between JavaScript Arrays And Ranges
    • 5.8 Named Ranges
    • 5.9 Practical Examples
    • 5.11 Concluding Remarks
    • 5.12 Summary
  • Chapter 6: MySQL And JDBC
    • 6.1 Introduction
    • 6.2 What Is JDBC?
    • 6.3 MySQL Preliminaries
    • 6.4 Connecting to a Cloud MySQL Database from the mysql Client
    • 6.5 An Overview of JDBC
    • 6.6 Note on Code Examples
    • 6.7 Connecting to the Database
    • 6.8 Create, Load, Query, Update and Delete a Database Table
    • 6.9 Prepared Statements
    • 6.10 Transactions
    • 6.11 Database Metadata
    • 6.12 A Practical GAS Example
    • 6.13 Summary
  • Chapter 7: User Interfaces - Menus and Forms
    • 7.1 Introduction
    • 7.2 Adding A Menu
    • 7.3 Building Forms With HtmlService
    • 7.3.3 Defining Form Layout in CSS
    • 7.4 Transferring Data from Google Sheets To an HtmlService Web Application
    • 7.5 Create Professional-looking Forms the Easy Way - Use Bootstrap
    • 7.6 Summary
  • Chapter 8: Google Drive, Folders, Files, And Permissions
    • 8.1 Introduction
    • 8.2 List Google Drive File And Folder Names
    • 8.3 Creating And Removing Files And Folders
    • 8.4 Adding Files To And Removing Files From Folders
    • 8.5 File And Folder Permissions
    • 8.6 Practical Examples
    • 8.7 Summary
  • Chapter 9: Email and Calendars
    • 9.1 Introduction
    • 9.2 Sending An Email Using MailApp
    • 9.3 Sending An Email With An Attachment Using MailApp
    • 9.4 GmailApp
    • 9.5 Calendars
    • 9.6 Summary
  • Appendix A: Excel VBA And Google Apps Script Comparison
    • Introduction
    • Spreadsheets and Sheets
    • Ranges
  • Appendix B: Final Notes
    • Additional Resources
    • JSLint
    • Getting Source code For This Book From Github
    • Blog Updates

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub