Updated: GAS Library - ManifestsApp

ManifestsApp was updated to v1.0.4.

  • v1.0.4 (February 12, 2020)

    • “runtimeVersion” got to be able to be got and set. Now, ‘STABLE’, ‘V8’, ‘DEPRECATED_ES5’ can be used as the value of “runtimeVersion”. For example, you can enable V8 with the following script.

      var r = ManifestsApp.setProjectId(projectId).setRuntimeVersion("V8");
      Logger.log(r);
      
    • As one important point, when “STABLE” and “DEPRECATED_ES5” are used for the Google Apps Script project created before 2020 as the value of “runtimeVersion”, the error of Syntax error: Illegal character. occurs. So please be careful this. This has been reported at the issuetracker.

Rearranging Columns on Google Spreadsheet using Google Apps Script

Gists

This is a sample script for rearranging the columns on Google Spreadsheet using Google Apps Script.

Sample script

In this sample script, the columns are rearranged with an array including the rearranged column indexes.

function rearrangeColumns(sheet, ar) {
  var obj = ar.reduce(function(ar, e, i) {
    return ar.concat({ from: e + 1, to: i + 1 });
  }, []);
  obj.sort(function(a, b) {
    return a.to < b.to ? -1 : 1;
  });
  obj.forEach(function(o) {
    if (o.from != o.to) sheet.moveColumns(sheet.getRange(1, o.from), o.to);
    obj.forEach(function(e, i) {
      if (e.from < o.from) obj[i].from += 1;
    });
  });
}

// Please run this function.
function main() {
  var sheet = SpreadsheetApp.getActiveSheet();
  var rearrangedColumnIndexes = [4, 3, 1, 0, 2];
  rearrangeColumns(sheet, rearrangedColumnIndexes);
}
  • rearrangedColumnIndexes is the indexes of rearranged columns.

Benchmark: Loop for Array Processing using Google Apps Script with V8

Gists

- February 9, 2020 - Published. - March 15, 2020 - Results of "for of" and "for of with iterator" were added.

Kanshi Tanaike

Introduction

Please be careful! This result can be only used for Google Apps Script.

There are a limit executing time for Google Apps Script (GAS). That is 6 minutes.1 So users always have to pay attention to reducing the process cost of the scripts. Especially, it is very important to know the process cost for the array processing, because the array processing is often used for spreadsheet and Google APIs. I have already reported “Benchmark: Loop for Array Processing using Google Apps Script”.2 At February 7, 2020, the V8 runtime got to be able to be used in my account. By this, it is considered that it is possibly changed the result of benchmark without V8 2. So I measured about this. In this report, the process cost of “loop” for the array processing using GAS has been investigated with V8 runtime.

V8 Runtime was added to Google Apps Script at February 7, 2020

Gists

In my environment, at February 7, 2020, when I opened the script editor of Google Apps Script, the following notification could be seen.

V8 Runtime was added to Google Apps Script at February 7, 2020

By this, I could notice that finally, the V8 Runtime has already been added to Google Apps Script. I think that this will be also the great news for a lot of users including me.

GAS Library - DateFinder

Overview

DateFinder is a GAS library for searching the date objects from the cell range on the sheet in the Spreadsheet and retrieving the searched range as the RangeList object using Google Apps Script (GAS).

Description

There is the Class TextFinder for searching the text from cells of the Spreadsheet using the Google Apps Script. But in this case, the date object in the cell is used as the string. Namely, the values for searching are used as the same with the values retrieved by getDisplayValues(). So for example, when there are the date objects in the cells with the various formats, the date cannot be searched by the Class TextFinder. So I created this library. When this library is used, the date objects in the cells can be retrieved by the date object and/or the range between 2 dates.

Updated goodls to v125

  • v1.2.5 (January 29, 2020)

    1. An option for selecting whether the top directory is created was added.
      • $ goodls -u [URL] --notcreatetopdirectory or $ goodls -u [URL] -ntd
      • When this option is NOT used (default situation), when a folder including sub-folders is downloaded, the top folder which is downloaded is created as the top directory under the working directory. When this option is used, the top directory is not created and all files and sub-folders under the top folder are downloaded under the working directory.
      • This feature request was implemented.

The detail information and how to get this are https://github.com/tanaikech/goodls.

URL Encode with Shift-JIS using Google Apps Script

Gists

This is a sample script for achieving the URL encode with Shift-JIS using Google Apps Script.

Unfortunately, there are no methods for directly achieving above in the methods of Google Apps Script. So it is required to prepare it as the script. In order to use Shift-JIS of the character set at Google Apps Script, it is required to use it as the binary data. Because, when the value of Shift-JIS is retrieved as the string by Google Apps Script, the character set is automatically changed to UTF-8. Please be careful this.

Libraries of gdoctableapp for golang, Node.js and python were updated to v110

Libraries of gdoctableapp for golang, Node.js and python were updated to v1.1.0