Skip to content

Instantly share code, notes, and snippets.

View andrewroberts's full-sized avatar
Cranking out the code... 👨‍💻

Andrew Roberts andrewroberts

Cranking out the code... 👨‍💻
View GitHub Profile
andrewroberts /
Last active July 7, 2017 11:58 — forked from hlecuanda/
Example using Stackdriver logging for debugging a custom function for sheets in Google Apps Script. / Writing a Caching custom function

Logging custom functions using stackdriver in google apps script

Recently, console logging became available for Google Apps Script projects. It used to be impossible to use the Log service that comes with the GAS runtime, but now all you need to do is throw an exception. Exceptions get logged in stackdriver logging and when enabled, unhandled exceptions will not stop your script execution. This adds up to nearly 0 lag if you are using this feature (?) by purposely throwing exceptions, and you can get creative with your error message to avoid having to expand stackdriver's log messages (which are pretty comprehensive stacktraces!)


andrewroberts /
Last active July 2, 2024 08:44 — forked from Spencer-Easton/
Example on how to export a Google sheet to various formats, includes most PDF options. Updated from comments in [Spencer Easton's Gist](
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped