GSheetsUtils Library for Google Apps Script
Maintained by the team at
What is a Google Apps Script (GAS) Library?
Libraries provide a convenient way for GAS developers to quickly share and re-use methods across projects. In the GAS code editor, Libraries also offer the advantage of having their top-level methods added to the auto-complete code assistant. When a library is well documented using JSDoc notation, the autocomplete becomes especially useful. Using libraries does create slightly slower performance, so source code should be copied and run locally for published Add-ons. Learn more here.
Why would I want to use GSheetsUtils?
For example the data shown below...
...would be returned by range.getValues() like this...
Whereas the GSheetsUtils.getRowsData() method would return it as...
We believe this object-based approach to row data offers several distinct advantages:
Reading and writing data is column-position-independent: Users can move columns in the sheet without changing the way your code runs. By contrast, code that references Sheets data by array index is highly fragile and prone to user error. Note: there remains some fragility due to the likelihood that a user will modify a header.
Moving data between Sheets is easier: Fewer translations between headers and keys means quicker and easier development, and it means that a "Student ID" in one sheet is treated just like a "Student ID" in another, for example.
From the Apps Script Code Editor, select the Resources -> Libraries... menu item.
Paste the library key MEtV19nFj3lNeMgJlb6GILfTE84O-IH7F where it says Find a Library and click Select. Choose the latest version and note the Library identifier, which is will be the library's class name in the Script editor. If necessary, the identifier can be changed.
...can be gotten here.
While it is not necessary to interact with the source code, you may choose to copy it into another project or fork it into your own published library if you prefer not to have an explicit dependency on the Amplified Labs codebase.