Mahmoud Maarouf
Mahmoud Maarouf

Reputation: 185

Automatically create a new Google Spreadsheet with Script Editor

How to automatically create a new Google Spreadsheet with Script Editor?

I know it seems obvious but I couldn't find an answer to this as everyone has only been interested in creating a sheet, instead of an entirely new spreadsheet automatically.

Upvotes: 0

Views: 101

Answers (1)

St3ph
St3ph

Reputation: 2290

To create anew spreadsheet refer to the create() method there : https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#createname

Code is really simple

function createNewSpreadsheet(){
  var ssNew = SpreadsheetApp.create("My New Spreadsheet");
  Logger.log(ssNew.getUrl());
}

And if you want to get the first tab

  var firstTab = ssNew.getSheets()[0] ;

And if you want to get the cell C15

  var cell = firstTab.getRange("C15");

Stéphane

Upvotes: 3

Related Questions