AppsScriptPulse

Learn how to improve Google Sheets performance

Image credit: Google

You can improve the performance of Google Sheets and speed up calculations.

Via Sourabh Choraria (@schoraria911) we picked up this tweet from
Michael Avrukin who is working on the Google Sheets help center documentation:

The page includes a number of useful tips to speed up Google Sheet calculations and whilst not specifically Google Apps Script related provides useful information on some things you can look out for when your Google Sheet starts getting slow.

Source: Learn how to improve Sheets performance

Bulk reset slicers in a Google Sheets, the Apps Script way

This article explains how the filtering criteria of Google Sheets slicers can be reset using a few lines of Apps Script code. Two different approaches are shown. The first one uses the Spreadsheet Service, while the second one draws upon the Google Sheets API using the Advanced Sheets Service. Additionally, some shortcomings and peculiarities of both methods are highlighted.

Kudos to Pablo Felip for taking the time to explore and write-up this post about Google Sheets ‘slicers’. It contains some very useful tips and advice about  interacting with them using Google Apps Script.

Source: Bulk reset slicers in a Google Spreadsheet, the Apps Script way

Google Apps Script library for parsing HTML form objects and adding the values to a Google Sheet

This is a Google Apps Script library for parsing the form object from HTML form and appending the submitted values to the Spreadsheet.

A common Google Apps Script use case is taking data from a webform and adding it to a Google Sheet. This can sometimes be quite painful has you have to handle the various input types and also write the data to the correct columns. The HtmlFormApp library makes this very straight forward and to illustrate once the library is added to your Apps Script project you can start appending data in a couple of lines of code:

// These are all options.
const obj = {
   formData: formData,
   spreadsheetId: "###",
   sheetName: "###",
   sheetId: "###",
   folderId: "###",
   headerConversion: {"header value of Spreadsheet": "name of HTML input tag",,,},
   ignoreHeader: true,
   choiceFormat: true,
   delimiterOfMultipleAnswers: "\n",
   valueAsRaw: true
};
const res = HtmlFormApp.appendFormData(obj);
console.log(res)

Click through to the source link for more details 👇

Source: GitHub – tanaikech/HtmlFormApp: This is a Google Apps Script library for parsing the form object from HTML form and appending the submitted values to the Spreadsheet.

How to Request Stripe Payments with Google Sheets – Digital Inspiration

Image credit: Amit Agarwal

How to use Google Sheets to generate Stripe payment links and request payments in any currency from your customers anywhere in the world!

Amit Agarwal continues an excellent series of payment themed posts with this latest contribution on integrating the new Stripe Payment Links API with Google Sheets. As noted by Amit this can be combined to make quick payment workflows. Click through for more details and the source code.

Source: How to Request Stripe Payments with Google Sheets – Digital Inspiration

Generate code verifier and challenge for OAuth2 with PKCE [Using the Twitter API v2 as user with OAuth2 in Google Apps Script] 

here’s how you can generate a cryptographically random code verifier, hash it using sha256 & derive it’s base64 encoded challenge in google apps script.

Continuing the crypto theme Sourabh Choraria has been geeking out with Proof Key for Code Exchange (PKCE) OAuth 2.0 authentication flows which be used in the new Twitter API when making requests on behalf of users.

If you are unfamiliar with PKCE, you can find out more in Okta’s description on how to use PKCE to Make Your Apps More Secure. You can follow Sourabh Choraria post to find out more about the Apps Script implementations of this and the good news for Twitter/Apps Script users is the sample is now committed to the Google Workspace OAuth2 Apps Script library samples as Twitter.gs

Source: generate code verifier & challenge for OAuth2 with PKCE

How to use Google Apps Script to process large amounts of data

Senbei is a traditional Japanese cracker made of rice. It is a very tasty cracker that goes well with Japanese tea, but there are also huge Senbeis as big as your face. What do you do when you eat such a big cracker? Usually, you would crush them into small pieces before eating them. The same can be said for processing huge data with Google Apps Script.

Some tips and tricks for handling script runtime and triggers total runtime quotas in Google Apps Script. Make sure you click through to another post from the author for code on An easy way to deal with Google Apps Script’s 6-minute limit.

Source: How to use Google Apps Script to process large amounts of data

Importing CSV data by keeping number formats of cells on Google Sheets using Google Apps Script

This is a sample script for importing a CSV data by keeping the number formats of cells on Google Spreadsheet using Google Apps Script.

When a CSV data is manually put using the default UI using the browser, it seems that the number formats of all cells cannot be kept. In order to import the CSV data to the cells with keeping the number formats, it is required to use a script as a workaround. In this workaround, Google Apps Script is used.

When the following sample script of Google Apps Script is run, a dialog is opened. And, when the CSV file is selected from your local PC on the dialog, the CSV file is loaded, and then, the CSV data is put to the active cell with keeping the number formats of cells.

The quoted post description explains everything you need about this solution and worth clicking through to see how the code works.

Source: Importing CSV Data by Keeping Number Formats of Cells on Google Spreadsheet using Google Apps Script

Archive Sheet data using tickboxes and Google Apps Script

Automatically move a row of data from one Google Sheet tab to another when a tickbox is selected.

Archive a row of data by ticking a box

Archive a row of data by ticking a box

The following Google Apps Script is designed to move a row of data from one Google Sheet tab to another when a tickbox has been selected in a given column. The tool was developed to help colleagues with automatically archiving data that had been actioned.

The tool uses an ‘onEdit(e) simple trigger’ to constantly monitor the Google Sheet for any changes in values. Is it specifically targeted at a tickbox-column only so that it does not archive rows of data on every edit of the Google Sheet.

Source: The Gift of Script: Archive Sheet data using tickboxes

Merging Google Sheets from multiple sources and encrypting selected columns – Desktop Liberation

This post introduces a library that can summarize selected columns from multiple sheets across multiple spreadsheets into 1 spreadsheet, as well as to optionally apply a public/private key data encryption scheme to selected columns, all via a simple JSON definition file.

Bruce Mcpherson continues to be one of my favourite Google Apps Script authors and often you get to gain an insight into his development process. This latest post is the latest in a series that follows a post on Super simple cipher library for Apps Script encryption and decryption. The source post shared here continues this journey, in particular, highlighting the use of Google Sheets Developer Metadata to store data bound to the spreadsheet.

Source: Merging sheets from multiple sources and encrypting selected columns – Desktop Liberation

Google Apps Script Release notes as an RSS Feed (scraping web pages with cheerio)

This enables you to register Apps Script Release Notes as RSS feed.

RSS data feeds might be less fashionable now, but I for one still rely on them as a way to aggregate and consume latest news. In a conversation with Pablo Felip and Kanshi Tanaike, this solution from Yuki Tanabe for turning the Google Apps Script release notes into an RSS feed was highlighted.  You can visit the source link for the RSS link to add to your feed aggregator.

Even if you are not a fan of RSS this project might be worth checking out as the solution implements the cheerio library for parsing/extracting content from HTML markup … or in other words a very simply way to use UrlFetchApp as a web scraper.

Source: GitHub – tanabee/google-apps-script-release-notes-feed: Apps Script Release notes RSS Feed