Last week, we talked about the best way to build front-ends for Google Apps Script. Today, letâs roll up our sleeves and dive in! đ
As I mentioned in my previous post, weâre going to create a super cool sidebar in Google Sheets thatâll help us select emojis with ease. đ Google Docs already has this functionality natively: simply head over to the âInsertâ menu, select âEmoji,â and voilĂ ! Youâll see a neat dialogue window with all emojis organized by category, as well as a handy search function:
However, we want more, so, weâll be building our own version. đ Unlike Docs, weâll have a full sidebar to work with, and clicking on an emoji wonât automatically insert it. Instead, itâll copy it into our buffer, so we can paste it wherever we need it. đ
That being said, letâs dive into using our most important tool: Vite. âĄ
Welcome to the Ultimate Google Ultimate Google Apps Script Front-End Development Guide!
If you are reading this post, then you likely have experience with Google Apps Script. Essentially, there are three types of front-ends that you can create with Apps Script:
Web apps
Modal/modeless dialogues
Sidebars
In this blog post series, we will only discuss HTML front-ends, as this is where you can create the most powerful and sophisticated user experiences. Unfortunately, the Card Service is outside the scope of this series, and it is not nearly as powerful as an HTML front-end. With that in mind, Google, how about allowing HTML front-ends for Workspace add-ons?
For read-heavy applications that donât involve components external to Apps Script accessing the cache and donât exceed the CacheService limits, use CacheService. For write-heavy applications or for when some external parts require access to the same cache, use Spreadsheet App.
An interesting report from Ignacio Lopezosa Serrano on the relative performance of CacheService and SpreadsheetApp for reading/writing data with Google Apps Script. Some surprising results and something I think to be kept in mind is how these tests compare to ‘real world’ conditions. As also pointed out in the post there are some service limitations of CacheService to keep in mind particularly around storage size limits.
This is a sample script for exporting Google Docs files (Spreadsheets, Documents, and so on) in PDF format with batch requests using Google Apps Script.
As a reference sample situation, in order to export 100 Google Document files as PDF files, when I tested this sample script, the processing time was about 150 seconds and no error occurred. And, I confirmed that 100 valid PDF files were created in my Google Drive.
Kanshi Tanaike has been busy again, this time looking at how you can handle batch exports from Google Docs, Sheets and Slides using Google Apps Script. There is quite a bit of engineering to get your head around but if you are looking for a copy/paste solution everything is well commented for you to drop this code into your own project. If you’d like more context about the solution there is a related post on Stack Overflow.
If you have ever worked with Google Apps Script (GAS), you may have found yourself in this situation. You want to move some files from some Google service to another, e.g., from Drive to a Google Cloud Storage Bucket. You get the file’s contents using GAS’s built-in service in the form of a Byte array. You pass this byte array to the URLFetchApp.fetch() function in the body.
All is going good and well, but then you notice. Why is it taking 30 seconds to upload a 10MB file? Am I doing something wrong? Is GAS not meant for this?
Don’t panic. I’ve been there, and I decided to take a closer look. Here’s what I found.
In this article Ignacio Lopezosa takes a deep dive into how to handle bytes in Google Apps Script, sharing his journey in finding a solution on how to share (large) files.
Google Apps Script is great and all (and itâs a great starting point for writing code to control spreadsheets) but it doesnât do all of the things I want it to. Namely, it doesnât run Python, only Javascript (actually App Script but itâs a small distinction).
We are going to write some App Script in this series, but it wonât be the powerhouse of our logic. Instead, we will use it to capture user input and proxy requests to our own API.
If you’ve spent a bit of time with Apps Script it’s very likely that you’ve used SpreadsheetApp or the Sheets advanced service to interact with Google Sheets. If you are interested in expanding your horizons and using different tooling for this job here’s a starter tutorial showing you how you can spin up a Google Cloud Run service using Terraform which will let you deploy a Python API application.
How to fix Apps Script file loading order and defintion visibility problems with an Exports object.
Itâs good practice to keep class and namespace definitions in separate files and avoid defining functions or variables in the global space. However, App Script doesnât give you control over the order in which it loads files. If you reference a class or a namespace from one script file, it may not yet be defined. This is where an Exports object comes in.
As your script projects get larger and you start splitting out across script files you may find you need a little more structure. Class and namespace definitions are a good way to structure your code. Even when you do this you can still encounter problems with parts of your script trying to run before they are fully loaded.
This was a particular issue when the V8 runtime launched in 2020. This was fixed in June 2022, but it can still be an issue depending on how declarations are made in your code. To find out more about why this happens and how to fix it this post by Bruce Mcpherson shows how an Exports object can be used to structure your code.
In this article Jahswill Essien describes how to use Google Sheets with Flutter via Google Apps Script.
This article assumes the following:
You have experience using the basics of Flutter and can call APIs and read an existing codebase
You have little to no understanding of Google Apps Script
You have some experience using Google Sheets or spreadsheets in general
I’m sure many of you reading this post will already be familiar with Google Apps Script and have little/no experience deploying Flutter apps but I also know a lot of Google Apps Script developers are keen to try new stuff.
If deploying mobile apps is a thing that interests you I’d highly recommend also looking at Google no/low code development platform, AppSheet, which enables you to quickly create/deploy apps often using Google Sheets as a backend. If, however, you need custom graphics or pixel perfect UI, solutions like Flutter would be my personal starting point. Enjoy!
Google Drive alone can handle small file management jobs, but for larger batches of files, it can be too much for a simple Drive script to manage. With Google Apps Script, even large batches can be executed within 6 minutes, offering businesses the monetary and time benefits of efficient file management. This report looks at how Google Apps Script improves file management with batch requests, judging its efficacy by measuring the benchmark.
We’ve regularly highlighted work from Kanshi Tanaike in Pulse and it’s nice to see it also being highlighted in the official Google Cloud Blog. I’m sure many Google Workspace developers, like me, have encountered issues with managing large volumes of Google Drive files. In the post Kanshi Tanaike highlights how batch methods can be used to greatly speed up the process when interacting with the Google Drive API.
Tank and Drv are SuperFetch plugins to emulate streaming and use the Drive REST API with Apps Script … This article will cover how to copy very large files using Tank to stream and Drv to upload and download partial content. The Apps Script Drive services have a limit on the size of files you can write, and very large memory usage can potentially cause Apps Script to fall over mysteriously
Clever stuff as always from Bruce Mcpherson, this time looking at how you can handle large files with Google Apps Script. We’ve featured some of Bruce’s other SuperFetch posts on Pulse, but developers can benefit from exploring the entire series so far on Bruce’s website. As well as SuperFetch plugins for Firebase and Twitter I’m personally interested in the evolution of the Google Drive client (Drv).