Using a color table

In Looking up color table, we covered how to use a color table to reference to make palettes using the functions described in Playing around with colors in VBA. But that was in Excel – now here’s the Google Apps Script Version.

The workbook

We’ll use the same workbook as in Google Script Color Ramp. The color table is one of the tabs below.

Copy of heatMap

Code for test Example

This code produces the example above.  It has many thousands of lines,  a bit too many for GAS to be effective. I am using caching  for both data and cell properties, and using Data manipulation Classes in Google Apps Script means that the GAS code is almost identical to the VBA code. It took about 10 minutes to convert this – but a lot longer to run it.

This is all that’s needed. The color ramp and caching utilities are provided in the mcpher script library.


Color manipulation

Playing around with colors in VBA had a bunch of functions for converting between color models. Here’s their translation to Google Apps Script. The functions used in Google Script Color Ramp are in the same module too.

Next Steps

For more like this, see  From VBA to Google Apps Script . For help and more information join our forum, follow the blog or follow me on twitter .