Skip to content

Instantly share code, notes, and snippets.

View ianthomaz's full-sized avatar

Ian Thomaz ianthomaz

View GitHub Profile
@hubgit
hubgit / list-files-in-folder.js
Created September 20, 2012 11:20
List all files in a folder (Google Apps Script)
function listFilesInFolder() {
var folder = DocsList.getFolder("Maudesley Debates");
var contents = folder.getFiles();
var file;
var data;
var sheet = SpreadsheetApp.getActiveSheet();
sheet.clear();

Google Apps Script Spreadsheet Utilities and Custom Functions#

These utilities are grouped into related files, for simpler copy & paste to your scripts.

ConvertA1.gs

A couple of helper functions to convert to & from A1 notation.

cellA1ToIndex( string cellA1, number index )

@mesgarpour
mesgarpour / appsScript_ListFilesFolders_ver.2.js
Last active July 18, 2024 06:09
[Google Apps Script] List all files & folders in a Google Drive folder, & write into a speadsheet
/*
* Copyright 2017 Mohsen Mesgarpour
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@whatsmate
whatsmate / send-whatsapp.gs
Last active July 16, 2023 11:05
Sending a WhatsApp message from Google Apps Script
function main() {
var destNumber = "12025550108"; // TODO: Specify the recipient's number here. NOT THE GATEWAY NUMBER!
var message = "Aloha, this is my first message.";
sendWhatsapp(destNumber, message);
}
function sendWhatsapp(destNumber, message) {
var instanceId = "YOUR_INSTANCE_ID_HERE"; // TODO: Replace it with your gateway instance ID here
var clientId = "YOUR_CLIENT_ID_HERE"; // TODO: Replace it with your Forever Green client ID here
@tanaikech
tanaikech / submit.md
Last active December 27, 2022 09:26
Enhanced onEdit(e) using Google Apps Script

Enhanced onEdit(e) using Google Apps Script

onEdit(e) which is used for the Edit event on Spreadsheet has the old value as e.oldValue. The specifications for this are as follows.

  1. When an user edited a single "A1" cell, e of onEdit(e) shows hoge for e.oldValue and fuga for e.value.
  2. When an user edited the "A1:A2" multiple cells, e.oldValue and e.value of onEdit(e) are not shown anything.
  3. When an user copied and pasted from other cell, e.oldValue and e.value of onEdit(e) are not shown anything.

This sample script was created to retrieve both the edited values and the old values for the range of edited cells. This is the modified e.oldValue.

@jalcantarab
jalcantarab / _jsonPuller.md
Last active June 3, 2024 10:49 — forked from crstamps2/jsonPuller
A Google apps script to pull json from a spreadsheet

JSON Puller - Google Apps Script

Transforms the data of a given Spreadsheet Sheet to JSON.

  • The frozen rows are taken as keys for the JSON.
  • The data taken for the values is only that after the frozen rows

Set up:

exportJSON(Spreadsheet) - transforms the data in the given sheet to JSON.

@mfyz
mfyz / gapp.js
Created January 13, 2020 19:26
Auto Increment (Sequence) in Google Sheets / Google Apps Script
function onEdit(e) {
// Auto increment number column name
var aiColumnName = 'A';
// The column that is tested, seq numbers will be
// given if this column is not empty.
var requieredColName = 'B'
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var worksheet = spreadsheet.getActiveSheet();
var aiColRange = worksheet.getRange(aiColumnName + '1:' + aiColumnName + '1000');