LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Saturday, October 14, 2017

スプレッドシートのURLを指定してデータを入力する

現在開いているスプレッドシートではなく、別のスプレッドシートのURLを指定してデータを入力するコードです。
The code below means "Input data to a sheet by a Spreadsheet's URL".

スプレッドシートの「ファイルID」についてはこちらをクリック
What is File ID? click here↑

コード.gs
function myFunction() {
  var ss = SpreadsheetApp.openByUrl("Spreadsheet URL");
  var sh = ss.getSheetByName("シート1");
  var range = sh.getRange("A1");
  range.setValue("hello");
}
意訳.gs
この処理は以下を実行する
指定したURLのスプレッドシートを開いて
シート1 という名前のシートを取得して
A1セルに
指定した値を入力する


シート名やシートIDによって、入力するシートを指定する必要があります。
It needs to identify the sheet by the name or id.


Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...