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
andrewroberts / exportSpreadsheet.gs
Last active July 2, 2024 08:44 — forked from Spencer-Easton/exportSpreadsheet.gs
Example on how to export a Google sheet to various formats, includes most PDF options. Updated from comments in [Spencer Easton's Gist](https://gist.github.com/Spencer-Easton/78f9867a691e549c9c70)
function exportSpreadsheet() {
//All requests must include id in the path and a format parameter
//https://docs.google.com/spreadsheets/d/{SpreadsheetId}/export
//FORMATS WITH NO ADDITIONAL OPTIONS
//format=xlsx //excel
//format=ods //Open Document Spreadsheet
//format=zip //html zipped
@andrewroberts
andrewroberts / StackTraces-Logging-GAS.md
Last active July 7, 2017 11:58 — forked from hlecuanda/StackTraces-Logging-GAS.md
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!)

Setup