Skip to content

Instantly share code, notes, and snippets.

@TheGreatGaspy
TheGreatGaspy / README.md
Created December 25, 2023 03:00 — forked from brainysmurf/README.md
Named parameters, required parameters, and interfaces

Interfaces in Javascript for Google Apps Scripts

I really like named parameters. I can live without them, but there is one place where I really need them. Cases in which I want to create a class and the paramters are guaranteed to be present, nothing extra. This is one way of implementing them. (It's kinda ugly, but kinda cool.)

Project Key

Either copy into your project, or use as a library: MWzXfEDYTWuJ_Xj0ap9H8-68b30WIDiE_

Wrong behaviour

@tanaikech
tanaikech / submit.md
Created December 22, 2023 06:20
Inserting Generated Text to Google Documents, Google Spreadsheets, and Google Slides using Gemini Pro API with Google Apps Script

Inserting Generated Text to Google Documents, Google Spreadsheets, and Google Slides using Gemini Pro API with Google Apps Script

Description

When the generated text can be automatically inserted into the cursor position of Google Document, Google Spreadsheet, and Google Slide, it will be useful for users. This report introduces sample scripts for achieving this.

Sample scripts

Here, I would like to introduce 3 sample scripts for a Google Document, a Google Spreadsheet, and a Google Slide.

@tanaikech
tanaikech / submit.md
Created December 19, 2023 23:28
Expanding Error Messages of Google Apps Script using Gemini Pro API with Google Apps Script

Expanding Error Messages of Google Apps Script using Gemini Pro API with Google Apps Script

Abstract

It is considered that when the current error message of Google Apps Script is expanded, it will be useful for a lot of users. This report introduces a sample script for expanding the error message of Google Apps Script using Gemini Pro API with Google Apps Script.

Introduction

// Mimic an Enum for Severity Levels
const Severity = {
INFO: 'INFO',
WARNING: 'WARNING',
ERROR: 'ERROR',
DEBUG: 'DEBUG'
};
/**
* Class representing a logger with functionality to log messages to a Google Spreadsheet.
/**
* Constants for boolean settings values.
*/
const YES = 'Yes';
const NO = 'No';
/**
* The Settings class provides a way to manage script parameters/settings
* directly within a Google Sheet, making it accessible for non-technical users.
*/
function getConfig(request) {
const config = communityConnector.getConfig();
config.newInfo()
.setId('instructions')
.setText('Enter Country Name to fetch university data.');
config.newTextInput()
.setId('country')
.setName('Country')
@TheGreatGaspy
TheGreatGaspy / submit.md
Created July 26, 2023 16:19 — forked from tanaikech/submit.md
Creating Multiple Buttons on Google Spreadsheet using Google Apps Script

Creating Multiple Buttons on Google Spreadsheet using Google Apps Script

This is a sample script for creating the multiple buttons on Google Spreadsheet using Google Apps Script.

Recently, I have got several contacts about this. I thought that when this is published, it might be useful for other users. So I published this sample script.

Sample script

@tanaikech
tanaikech / submit.md
Created July 7, 2023 02:33
Copying Google Spreadsheet by Removing Container-Bound Script Using Google Apps Script

Copying Google Spreadsheet by Removing Container-Bound Script Using Google Apps Script

This is a sample script for copying a Google Spreadsheet including a container-bound script by removing the container-bound script using Google Apps Script.

When you want to copy a Google Google Spreadsheet including a container-bound script by removing the container-bound script using Google Apps Script, this could be achieved by using "get" and "create" methods of Sheets API before. The sample script is as follows.

const obj = Sheets.Spreadsheets.get(
@tanaikech
tanaikech / submit.md
Created May 21, 2023 06:49
Converting Google Spreadsheet to HTML Table using Google Apps Script

Converting Google Spreadsheet to HTML Table using Google Apps Script

This is a sample script for converting Google Spreadsheet to an HTML table using Google Apps Script.

There is the case that it is required to convert a sheet in a Google Spreadsheet to an HTML table. For example, there might be a situation that a sheet in a Google Spreadsheet is sent as an email including an HTML table. And, there might be a situation in which a sheet in a Google Spreadsheet is published to an HTML page including the converted HTML table. I have published the method for achieving this before. Ref But, in that case, the column width, the row height, merged cells, and the images in the cells couldn't be used. When those are included in the script, the script becomes complicated. So, I couldn't include it. But, recently, I have come up with a simple method for achieving this. In this post. I would like to introduce

@tanaikech
tanaikech / submit.md
Last active March 27, 2024 00:55
Importing Microsoft Excel to Google Spreadsheet using Custom Function with Google Apps Script

Importing Microsoft Excel to Google Spreadsheet using Custom Function with Google Apps Script

This is a sample script for importing Microsoft Excel (XLSX) data to Google Spreadsheet using a custom function with Google Apps Script.

Usage

1. Install SheetJS library.