Samples

Script lab provides a lot of sample code to help you get started.
Press the Code button on the Ribbon to display the Code task pane.
Press the Hamburger button to switch to the Samples and Snippets pane and choose Samples.
Menu - (Hamburger Button) Toggles between the Samples window and the Code Editor window.
New Snippet - (Plus Sign) Displays the Code Editor and creates a New Code Snippet containing some boilerplate text.
My Snippets - Displays the My Snippets window displaying a list of your saved snippets.
Samples - Displays the list of code samples. There are lots of categories including basic, advanced and just for fun.
Import - Allows you to import a code snippet from the GitHub website.

alt text

Most of the samples have been written using TypeScript which is just an extension of JavaScript.


Running a Sample

Lets run the sample "Basic API call (JavaScript)".
As soon as you click on a sample from the list, the Code Editor will be displayed in the pane.
To run this code choose (Run > Run in this pane).

alt text

The following HTML page will be displayed allowing you to highlight a range and apply shading.

alt text

Highlight the cell range "B3:F8" and press "Highlight selected range" to colour these cells yellow.

alt text

The console at the bottom of the code pane will display the range address.

alt text

Editing a Sample

To edit the code click on the backwards arrow in the corner to display the Code Editor.
Instead of the cell range being shaded "yellow" lets change the colour to "blue".
The Code Editor has line numbers down the left hand side, find line number 6.

alt text

Change the colour to "blue".
Add another line below to change the Fill Pattern to Grey16.

alt text

Run this code again (Run > Run in this pane).
Highlight the cell range "B9:F12" and press "Highlight selected range" to apply this new cell formatting.

alt text

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext