app script get range code example

Example 1: google script get sheet size

// This example assumes there is a sheet named "first"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var first = ss.getSheetByName("first");
Logger.log(first.getMaxColumns());
// getMaxColumns() returns the current number of columns in the sheet,
// regardless of content.

Example 2: getranges google script

let SS = APP.getActiveSpreadsheet();
let sheetIndex0 = SS.getSheets()[0];

sheetIndex0.getRangeList(['A1', 'B1:C7']).setHorizontalAlignment("center");

Tags:

Misc Example