Class Spreadsheet

スプレッドシート

Google スプレッドシートのファイルにアクセスして変更する。一般的な操作は、新しいシートの追加や できます。

メソッド

メソッド戻り値の型概要
addDeveloperMetadata(key)Spreadsheet指定されたキーを持つデベロッパー メタデータを最上位のスプレッドシートに追加します。
addDeveloperMetadata(key, visibility)Spreadsheet指定されたキーと公開設定を持つデベロッパー メタデータをスプレッドシートに追加します。
addDeveloperMetadata(key, value)Spreadsheet指定されたキーと値を持つデベロッパー メタデータをスプレッドシートに追加します。
addDeveloperMetadata(key, value, visibility)Spreadsheet指定されたキー、値、公開設定を持つデベロッパー メタデータをスプレッドシートに追加します。
addEditor(emailAddress)Spreadsheet指定されたユーザーを Spreadsheet の編集者のリストに追加します。
addEditor(user)Spreadsheet指定されたユーザーを Spreadsheet の編集者のリストに追加します。
addEditors(emailAddresses)Spreadsheet指定されたユーザー配列を Spreadsheet の編集者のリストに追加します。
addMenu(name, subMenus)voidスプレッドシート UI に新しいメニューを作成します。
addViewer(emailAddress)Spreadsheet指定したユーザーを Spreadsheet の閲覧者のリストに追加します。
addViewer(user)Spreadsheet指定したユーザーを Spreadsheet の閲覧者のリストに追加します。
addViewers(emailAddresses)Spreadsheet指定されたユーザーの配列を Spreadsheet の閲覧者のリストに追加します。
appendRow(rowContents)Sheetシート内の現在のデータ領域の下部に 1 行を追加します。
autoResizeColumn(columnPosition)Sheet指定された列の幅をその内容に合わせて設定します。
copy(name)Spreadsheetスプレッドシートをコピーして、新しいスプレッドシートを返します。
createDeveloperMetadataFinder()DeveloperMetadataFinder次のスコープ内のデベロッパー メタデータを検出するための DeveloperMetadataFinder を返します。 このスプレッドシートにあります。
createTextFinder(findText)TextFinderスプレッドシートのテキスト ファインダーを作成します。このファインダーを使用して、テキストを検索、置換できます。 表示されます。
deleteActiveSheet()Sheet現在アクティブなシートを削除します。
deleteColumn(columnPosition)Sheet指定された列位置の列を削除します。
deleteColumns(columnPosition, howMany)void指定された列位置から始まる複数の列を削除します。
deleteRow(rowPosition)Sheet指定された行位置の行を削除します。
deleteRows(rowPosition, howMany)void指定された行の位置から始まる複数の行を削除します。
deleteSheet(sheet)void指定したシートを削除します。
duplicateActiveSheet()Sheetアクティブなシートを複製し、アクティブなシートにします。
getActiveCell()Rangeこのシート内のアクティブなセルを返します。
getActiveRange()Rangeアクティブ シートで選択した範囲を返します。アクティブ範囲がない場合は null を返します。
getActiveRangeList()RangeListアクティブ シート内のアクティブな範囲のリストを返します。アクティブなものがない場合は null を返します。 あります。
getActiveSheet()Sheetスプレッドシート内のアクティブなシートを取得します。
getAs(contentType)Blobこのオブジェクト内のデータを、指定されたコンテンツ タイプに変換された blob として返します。
getBandings()Banding[]このスプレッドシート内のすべてのバンドを返します。
getBlob()Blobこのオブジェクト内のデータを blob として返します。
getColumnWidth(columnPosition)Integer指定された列の幅をピクセル単位で取得します。
getCurrentCell()Rangeアクティブ シートの現在のセルを返します。現在のセルがない場合は null を返します。
getDataRange()Rangeデータが存在するディメンションに対応する Range を返します。
getDataSourceFormulas()DataSourceFormula[]データソースの数式をすべて取得します。
getDataSourcePivotTables()DataSourcePivotTable[]データソースのピボット テーブルをすべて取得します。
getDataSourceRefreshSchedules()DataSourceRefreshSchedule[]このスプレッドシートの更新スケジュールを取得します。
getDataSourceSheets()DataSourceSheet[]スプレッドシート内のすべてのデータソース シートを返します。
getDataSourceTables()DataSourceTable[]すべてのデータソース テーブルを取得します。
getDataSources()DataSource[]スプレッドシート内のすべてのデータソースを返します。
getDeveloperMetadata()DeveloperMetadata[]最上位のスプレッドシートに関連付けられているデベロッパー メタデータを取得します。
getEditors()User[]この Spreadsheet の編集者のリストを取得します。
getFormUrl()Stringこのスプレッドシートに回答を送信するフォームの URL を返します。そうでない場合は null を返します。 このスプレッドシートにはフォームが関連付けられていません。
getFrozenColumns()Integer固定列の数を返します。
getFrozenRows()Integer固定行の数を返します。
getId()Stringこのスプレッドシートの一意の識別子を取得します。
getImages()OverGridImage[]シート上のグリッド上のすべての画像を返します。
getIterativeCalculationConvergenceThreshold()Number反復計算で使用されるしきい値を返します。
getLastColumn()Integerコンテンツを含む最後の列の位置を返します。
getLastRow()Integerコンテンツを含む最後の行の位置を返します。
getMaxIterativeCalculationCycles()Integer反復計算で使用する反復処理の最大数を返します。
getName()Stringドキュメントの名前を取得します。
getNamedRanges()NamedRange[]このスプレッドシート内のすべての名前付き範囲を取得します。
getNumSheets()Integerこのスプレッドシート内のシート数を返します。
getOwner()Userドキュメントのオーナーを返します。共有ドライブ内のドキュメントの場合は null を返します。
getPredefinedSpreadsheetThemes()SpreadsheetTheme[]事前定義テーマのリストを返します。
getProtections(type)Protection[]スプレッドシート内のすべての保護されている範囲またはシートを表すオブジェクトの配列を取得します。
getRange(a1Notation)RangeA1 表記または R1C1 表記で指定された範囲を返します。
getRangeByName(name)Range名前付き範囲を返します。指定された名前の範囲が見つからない場合は null を返します。
getRangeList(a1Notations)RangeList指定された同じシートの範囲を表す RangeList コレクションを返します。 A1 表記または R1C1 表記の空でないリストで表します。
getRecalculationInterval()RecalculationIntervalこのスプレッドシートの計算間隔を返します。
getRowHeight(rowPosition)Integer指定された行の高さをピクセル単位で取得します。
getSelection()Selectionスプレッドシート内の現在の Selection を返します。
getSheetByName(name)Sheet指定した名前のシートを返します。
getSheetId()Integerこのオブジェクトによって表されるシートの ID を返します。
getSheetName()Stringシート名を返します。
getSheetValues(startRow, startColumn, numRows, numColumns)Object[][]指定された座標を始点とする、この範囲の値の長方形のグリッドを返します。
getSheets()Sheet[]このスプレッドシート内のすべてのシートを取得します。
getSpreadsheetLocale()Stringスプレッドシートの言語 / 地域を取得します。
getSpreadsheetTheme()SpreadsheetThemeスプレッドシートの現在のテーマを返します。テーマが適用されていない場合は null を返します。
getSpreadsheetTimeZone()Stringスプレッドシートのタイムゾーンを取得します。
getUrl()String指定したスプレッドシートの URL を返します。
getViewers()User[]この Spreadsheet の閲覧者とコメント投稿者のリストを取得します。
hideColumn(column)void指定された範囲内の列を非表示にします。
hideRow(row)void指定した範囲の行を非表示にします。
insertColumnAfter(afterPosition)Sheet指定された列位置の後に列を挿入します。
insertColumnBefore(beforePosition)Sheet指定された列位置の前に列を挿入します。
insertColumnsAfter(afterPosition, howMany)Sheet指定された列の位置の後に、指定された数の列を挿入します。
insertColumnsBefore(beforePosition, howMany)Sheet指定された列位置の前に複数の列を挿入します。
insertDataSourceSheet(spec)DataSourceSheetスプレッドシートに新しい DataSourceSheet を挿入し、データの実行を開始します。
insertImage(blobSource, column, row)OverGridImageドキュメントの指定された行と列の Spreadsheet を画像として挿入します。
insertImage(blobSource, column, row, offsetX, offsetY)OverGridImageドキュメントの指定された行と列に Spreadsheet を画像として挿入します。 ピクセル オフセット。
insertImage(url, column, row)OverGridImageドキュメントの指定された行と列に画像を挿入します。
insertImage(url, column, row, offsetX, offsetY)OverGridImageドキュメントの指定された行と列に、ピクセル オフセットで画像を挿入します。
insertRowAfter(afterPosition)Sheet指定された行位置の後に行を挿入します。
insertRowBefore(beforePosition)Sheet指定された行位置の前に行を挿入します。
insertRowsAfter(afterPosition, howMany)Sheet指定された行位置の後に複数の行を挿入します。
insertRowsBefore(beforePosition, howMany)Sheet指定された行の位置の前に複数の行を挿入します。
insertSheet()Sheetデフォルトのシート名を使用して、スプレッドシートに新しいシートを挿入します。
insertSheet(sheetIndex)Sheetスプレッドシートの指定されたインデックスに新しいシートを挿入します。
insertSheet(sheetIndex, options)Sheetスプレッドシートの指定されたインデックスに新しいシートを挿入します。必要に応じて高度なオプションを使用します。 渡します。
insertSheet(options)Sheetデフォルトのシート名とオプションの詳細設定を使用して、新しいシートをスプレッドシートに挿入します 渡します。
insertSheet(sheetName)Sheet指定した名前の新しいシートをスプレッドシートに挿入します。
insertSheet(sheetName, sheetIndex)Sheetスプレッドシートの指定されたインデックスに、指定された名前で新しいシートを挿入します。
insertSheet(sheetName, sheetIndex, options)Sheetスプレッドシートの指定されたインデックスに指定された名前で新しいシートを挿入し、 高度な引数。
insertSheet(sheetName, options)Sheet指定した名前の新しいシートをスプレッドシートに挿入します。必要に応じて高度なオプションを使用します。 渡します。
insertSheetWithDataSourceTable(spec)Sheetスプレッドシートに新しいシートを挿入し、そのシート全体に DataSourceTable を作成します。 スプレッドシート全体を実行し、データの実行を開始します。
isColumnHiddenByUser(columnPosition)Boolean指定された列がユーザーによって非表示かどうかを返します。
isIterativeCalculationEnabled()Booleanこのスプレッドシートで反復計算が有効になっているかどうかを返します。
isRowHiddenByFilter(rowPosition)Boolean指定した行が(フィルタ表示ではなく)フィルタによって非表示になっているかどうかを返します。
isRowHiddenByUser(rowPosition)Boolean指定した行がユーザーによって非表示かどうかを返します。
moveActiveSheet(pos)voidアクティブなシートをシートリストの指定された位置に移動します。
moveChartToObjectSheet(chart)Sheet新しい SheetType.OBJECT シートを作成し、指定されたグラフをそのシートに移動します。
refreshAllDataSources()voidサポートされているすべてのデータソースとそれらにリンクされたデータソース オブジェクトを更新します(無効なものはスキップします) 作成します。
removeEditor(emailAddress)SpreadsheetSpreadsheet の編集者のリストから指定したユーザーを削除します。
removeEditor(user)SpreadsheetSpreadsheet の編集者のリストから指定したユーザーを削除します。
removeMenu(name)voidaddMenu(name, subMenus) が追加したメニューを削除します。
removeNamedRange(name)void指定された名前の名前付き範囲を削除します。
removeViewer(emailAddress)SpreadsheetSpreadsheet の閲覧者と閲覧者(コメント可)のリストから指定したユーザーを削除します。
removeViewer(user)SpreadsheetSpreadsheet の閲覧者と閲覧者(コメント可)のリストから指定したユーザーを削除します。
rename(newName)voidドキュメントの名前を変更します。
renameActiveSheet(newName)void現在アクティブなシートを、指定した新しい名前に変更します。
resetSpreadsheetTheme()SpreadsheetTheme適用したテーマを削除し、スプレッドシートのデフォルトのテーマを設定します。
setActiveRange(range)Range指定した範囲をアクティブ シートの active range として設定します。 範囲内の左上のセルを current cell として指定します。
setActiveRangeList(rangeList)RangeList指定された範囲リストを active ranges ブロックとして設定します。 クリックします。
setActiveSelection(range)Rangeこのシートの有効な選択領域を設定します。
setActiveSelection(a1Notation)RangeA1 表記または R1C1 表記で指定されたとおりに、アクティブな選択を設定します。
setActiveSheet(sheet)Sheet指定したシートを、スプレッドシート内のアクティブなシートに設定します。
setActiveSheet(sheet, restoreSelection)Sheet指定したシートをスプレッドシート内のアクティブなシートに設定します。復元するオプションも用意されています。 そのシート内の最新の選択項目が表示されます。
setColumnWidth(columnPosition, width)Sheet指定された列の幅をピクセル単位で設定します。
setCurrentCell(cell)Range指定されたセルを current cell として設定します。
setFrozenColumns(columns)void指定された列数を固定します。
setFrozenRows(rows)void指定された行数を固定します。
setIterativeCalculationConvergenceThreshold(minThreshold)Spreadsheet反復計算の最小しきい値を設定します。
setIterativeCalculationEnabled(isEnabled)Spreadsheetこのスプレッドシートで反復計算を有効にするかどうかを設定します。
setMaxIterativeCalculationCycles(maxIterations)Spreadsheet反復処理の際に実行する計算の最大反復回数を設定します 計算します。
setNamedRange(name, range)void範囲に名前を付けます。
setRecalculationInterval(recalculationInterval)Spreadsheetこのスプレッドシートを再計算する頻度を設定します。
setRowHeight(rowPosition, height)Sheet指定された行の行の高さをピクセル単位で設定します。
setSpreadsheetLocale(locale)voidスプレッドシートの言語 / 地域を設定します。
setSpreadsheetTheme(theme)SpreadsheetThemeスプレッドシートにテーマを設定します。
setSpreadsheetTimeZone(timezone)voidスプレッドシートのタイムゾーンを設定します。
show(userInterface)voidユーザーのブラウザの中央に配置されたダイアログに、カスタム ユーザー インターフェース コンポーネントを表示します。 表示されなくなります。
sort(columnPosition)Sheetシートを列を基準に昇順で並べ替えます。
sort(columnPosition, ascending)Sheetシートを列で並べ替えます。
toast(msg)void指定されたメッセージで、スプレッドシートの右下にポップアップ ウィンドウを表示します。
toast(msg, title)voidスプレッドシートの右下に、指定されたメッセージとポップアップ ウィンドウを表示する できます。
toast(msg, title, timeoutSeconds)void指定されたタイトルのスプレッドシートの右下にポップアップ ウィンドウを表示する メッセージが一定時間表示されます。
unhideColumn(column)void指定された範囲の列を再表示します。
unhideRow(row)void指定した範囲の行を再表示します。
updateMenu(name, subMenus)voidaddMenu(name, subMenus) が追加したメニューを更新します。
waitForAllDataExecutionsCompletion(timeoutInSeconds)voidスプレッドシートで現在実行されているすべての実行が完了するまで待機し、次の時間が経過するとタイムアウトします。 指定されています。

詳細なドキュメント

addDeveloperMetadata(key)

指定されたキーを持つデベロッパー メタデータを最上位のスプレッドシートに追加します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Adds the key 'NAME' in the developer metadata for the spreadsheet.
ss.addDeveloperMetadata('NAME')

// Gets the first developer metadata object and logs its key.
const developerMetaData = ss.getDeveloperMetadata()[0]
console.log(developerMetaData.getKey())

パラメータ

名前説明
keyString新しいデベロッパー メタデータのキー。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addDeveloperMetadata(key, visibility)

指定されたキーと公開設定を持つデベロッパー メタデータをスプレッドシートに追加します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Adds the key 'NAME' in the developer metadata for the spreadsheet and sets the visibility
// to the developer project that created the metadata.
ss.addDeveloperMetadata('NAME', SpreadsheetApp.DeveloperMetadataVisibility.PROJECT);

// Gets the first developer metadata object and logs its key and visibility setting.
const developerMetaData = ss.getDeveloperMetadata()[0];
console.log(developerMetaData.getKey());
console.log(`Key: ${developerMetaData.getKey()},
.             Visibility: ${developerMetaData.getVisibility()}`);

パラメータ

名前説明
keyString新しいデベロッパー メタデータのキー。
visibilityDeveloperMetadataVisibility新しいデベロッパー メタデータの公開設定。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addDeveloperMetadata(key, value)

指定されたキーと値を持つデベロッパー メタデータをスプレッドシートに追加します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Adds the key 'NAME' and sets the value to 'GOOGLE' in the developer metadata for the
// spreadsheet.
ss.addDeveloperMetadata('NAME', 'GOOGLE');

// Gets the first developer metadata object and logs its key and value.
const developerMetaData = ss.getDeveloperMetadata()[0];
console.log(developerMetaData.getKey());
console.log(`Key: ${developerMetaData.getKey()}, Value: ${developerMetaData.getValue()}`);

パラメータ

名前説明
keyString新しいデベロッパー メタデータのキー。
valueString新しいデベロッパー メタデータの値。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addDeveloperMetadata(key, value, visibility)

指定されたキー、値、公開設定を持つデベロッパー メタデータをスプレッドシートに追加します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Adds the key 'NAME', sets the value to 'GOOGLE', and sets the visibility
// to any developer project with document access.
ss.addDeveloperMetadata('NAME', 'GOOGLE', SpreadsheetApp.DeveloperMetadataVisibility.DOCUMENT);

// Gets the first developer metadata object and logs its key, value, and visibility setting.
const developerMetaData = ss.getDeveloperMetadata()[0];
console.log(`Key: ${developerMetaData.getKey()},
             Value: ${developerMetaData.getValue()},
             Visibility: ${developerMetaData.getVisibility()}`);

パラメータ

名前説明
keyString新しいデベロッパー メタデータのキー。
valueString新しいデベロッパー メタデータの値。
visibilityDeveloperMetadataVisibility新しいデベロッパー メタデータの公開設定。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addEditor(emailAddress)

指定されたユーザーを Spreadsheet の編集者のリストに追加します。ユーザーがすでに 閲覧者のリストに含まれていた場合、このメソッドでは閲覧者のリストからユーザーを昇格できます。

パラメータ

名前説明
emailAddressString追加するユーザーのメールアドレス。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addEditor(user)

指定されたユーザーを Spreadsheet の編集者のリストに追加します。ユーザーがすでに 閲覧者のリストに含まれていた場合、このメソッドでは閲覧者のリストからユーザーを昇格できます。

パラメータ

名前説明
userUser追加するユーザーの表現。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addEditors(emailAddresses)

指定されたユーザー配列を Spreadsheet の編集者のリストに追加します。もし ユーザーがすでに閲覧者リストに含まれていた場合、この方法では閲覧者リストから昇格します。 できます。

パラメータ

名前説明
emailAddressesString[]追加するユーザーのメールアドレスの配列。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addMenu(name, subMenus)

スプレッドシート UI に新しいメニューを作成します。

各メニュー エントリでユーザー定義関数が実行されます。通常は onOpen() 関数から呼び出し、スプレッドシートの読み込み時にメニューが自動的に作成されるようにします。

// The onOpen function is executed automatically every time a Spreadsheet is loaded
function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var menuEntries = [];
  // When the user clicks on "addMenuExample" then "Menu Entry 1", the function function1 is
  // executed.
  menuEntries.push({name: "Menu Entry 1", functionName: "function1"});
  menuEntries.push(null); // line separator
  menuEntries.push({name: "Menu Entry 2", functionName: "function2"});

  ss.addMenu("addMenuExample", menuEntries);
}

パラメータ

名前説明
nameString作成するメニューの名前。
subMenusObject[]name パラメータと functionName パラメータを含む JavaScript マップの配列。付属のライブラリ( Library.libFunction1 など)の関数を使用できます。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addViewer(emailAddress)

指定したユーザーを Spreadsheet の閲覧者のリストに追加します。ユーザーがすでに エディタのリストに含まれていると、このメソッドは機能しません。

パラメータ

名前説明
emailAddressString追加するユーザーのメールアドレス。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addViewer(user)

指定したユーザーを Spreadsheet の閲覧者のリストに追加します。ユーザーがすでに エディタのリストに含まれていると、このメソッドは機能しません。

パラメータ

名前説明
userUser追加するユーザーの表現。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

addViewers(emailAddresses)

指定されたユーザーの配列を Spreadsheet の閲覧者のリストに追加します。もし ユーザーがすでに編集者リストに含まれていた場合、このメソッドでは効果がありません。

パラメータ

名前説明
emailAddressesString[]追加するユーザーのメールアドレスの配列。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

appendRow(rowContents)

シート内の現在のデータ領域の下部に 1 行を追加します。セルの内容の先頭か = の場合、数式として解釈されます。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Appends a new row with 3 columns to the bottom of the current
// data region in the sheet containing the values in the array.
sheet.appendRow(["a man", "a plan", "panama"]);

パラメータ

名前説明
rowContentsObject[]シートの最後の行の後に挿入する値の配列。

戻る

Sheet - メソッド チェーンに役立つシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

autoResizeColumn(columnPosition)

指定された列の幅をその内容に合わせて設定します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

sheet.getRange('a1').setValue('Whenever it is a damp, drizzly November in my soul...');

// Sets the first column to a width which fits the text
sheet.autoResizeColumn(1);

パラメータ

名前説明
columnPositionIntegerサイズを変更する特定の列の位置。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

copy(name)

スプレッドシートをコピーして、新しいスプレッドシートを返します。

// This code makes a copy of the current spreadsheet and names it appropriately
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.copy("Copy of " + ss.getName());

パラメータ

名前説明
nameStringコピーの名前。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

createDeveloperMetadataFinder()

次のスコープ内のデベロッパー メタデータを検出するための DeveloperMetadataFinder を返します。 このスプレッドシートにあります。デフォルトでは、スプレッドシートに関連付けられているすべてのメタデータが考慮されますが、 スプレッドシート、行、列です。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Adds developer metadata to the spreadsheet.
ss.addDeveloperMetadata('NAME', 'CHARLIE');
ss.addDeveloperMetadata('COMPANY', 'EXAMPLE ORGANIZATION');
ss.addDeveloperMetadata('TECHNOLOGY', 'JAVASCRIPT');

// Creates a developer metadata finder.
const developerMetadataFinder = ss.createDeveloperMetadataFinder();

// Finds the developer metadata objects with 'COMPANY' as the key.
const googleMetadataFromSpreadsheet = developerMetadataFinder.withKey('COMPANY').find();

// Gets the first result of developer metadata that has the key 'COMPANY' and logs its value.
console.log(googleMetadataFromSpreadsheet[0].getValue());

戻る

DeveloperMetadataFinder - このスプレッドシートのスコープ内でメタデータを検索するデベロッパー メタデータ ファインダー。


createTextFinder(findText)

スプレッドシートのテキスト ファインダーを作成します。これは、スプレッドシート内のテキストの検索と置換に使用できます。 表示されます。検索はスプレッドシートの最初のシートから開始されます。

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();

// Creates  a text finder.
var textFinder = spreadsheet.createTextFinder('dog');

// Returns the first occurrence of 'dog' in the spreadsheet.
var firstOccurrence = textFinder.findNext();

// Replaces the last found occurrence of 'dog' with 'cat' and returns the number
// of occurrences replaced.
var numOccurrencesReplaced = findOccurrence.replaceWith('cat');

パラメータ

名前説明
findTextString検索するテキスト。

戻る

TextFinder - スプレッドシートの TextFinder


deleteActiveSheet()

現在アクティブなシートを削除します。

// The code below deletes the currently active sheet and stores the new active sheet in a
// variable
var newSheet = SpreadsheetApp.getActiveSpreadsheet().deleteActiveSheet();

戻る

Sheet - 新しいアクティブ シート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

deleteColumn(columnPosition)

指定された列位置の列を削除します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Columns start at "1" - this deletes the first column
sheet.deleteColumn(1);

パラメータ

名前説明
columnPositionInteger列の位置。最初の列は 1 から始まります。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

deleteColumns(columnPosition, howMany)

指定された列位置から始まる複数の列を削除します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Columns start at "1" - this deletes the first two columns
sheet.deleteColumns(1, 2);

パラメータ

名前説明
columnPositionInteger削除する最初の列の位置。
howManyInteger削除する列の数。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

deleteRow(rowPosition)

指定された行位置の行を削除します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Rows start at "1" - this deletes the first row
sheet.deleteRow(1);

パラメータ

名前説明
rowPositionInteger行の位置(最初の行は 1 から始まります)。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

deleteRows(rowPosition, howMany)

指定された行の位置から始まる複数の行を削除します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Rows start at "1" - this deletes the first two rows
sheet.deleteRows(1, 2);

パラメータ

名前説明
rowPositionInteger削除する最初の行の位置。
howManyInteger削除する行数。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

deleteSheet(sheet)

指定したシートを削除します。

// The code below deletes the specified sheet.
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName('My Sheet');
ss.deleteSheet(sheet);

パラメータ

名前説明
sheetSheet削除するシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

duplicateActiveSheet()

アクティブなシートを複製し、アクティブなシートにします。

// The code below makes a duplicate of the active sheet
SpreadsheetApp.getActiveSpreadsheet().duplicateActiveSheet();

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getActiveCell()

このシート内のアクティブなセルを返します。

注: getCurrentCell() の使用をおすすめします。これにより、現在の セルがハイライト表示されます。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
// Returns the active cell
var cell = sheet.getActiveCell();

戻る

Range - 現在アクティブなセル

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getActiveRange()

アクティブ シートで選択した範囲を返します。アクティブ範囲がない場合は null を返します。条件 複数の範囲が選択されている場合、このメソッドでは、最後に選択された範囲のみが返されます。

「有効範囲」という用語ユーザーがアクティブ シートで選択した範囲。 カスタム関数では、アクティブに再計算されているセルを指します。

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var activeRange = sheet.getActiveRange();

戻る

Range - アクティブ範囲

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

関連情報


getActiveRangeList()

アクティブ シート内のアクティブな範囲のリストを返します。アクティブなものがない場合は null を返します。 あります。

範囲が 1 つ選択されている場合、これは getActiveRange() 呼び出しとして動作します。

var sheet = SpreadsheetApp.getActiveSheet();
// Returns the list of active ranges.
var activeRangeList = sheet.getActiveRangeList();

戻る

RangeList - アクティブな範囲のリスト

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

関連情報


getActiveSheet()

スプレッドシート内のアクティブなシートを取得します。

スプレッドシート内のアクティブなシートとは、スプレッドシートに表示されているシートのことです。 UI です。

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();

戻る

Sheet - スプレッドシート内のアクティブなシート。


getAs(contentType)

このオブジェクト内のデータを、指定されたコンテンツ タイプに変換された blob として返します。この メソッドにより、ファイル名に適切な拡張子(例: myfile.pdf)が追加されます。ただし、 ファイル名の最後のピリオド(ある場合)に続く部分は、 指定します。したがって、「ShoppingList.12.25.2014」となります。が以下に変換される: 「ShoppingList.12.25.pdf」

コンバージョンの 1 日あたりの割り当てを確認するには、Google Cloud の割り当て サービス。新しく作成された Google Workspace ドメインには一時的に厳格な できます。

パラメータ

名前説明
contentTypeString変換先の MIME タイプ。ほとんどの blob の場合、'application/pdf' は次のようになります。 唯一の有効な選択肢となりますBMP、GIF、JPEG、PNG 形式の画像の場合は、'image/bmp''image/gif''image/jpeg''image/png' のいずれかも可 有効です。Google ドキュメントのドキュメントの場合は、'text/markdown' も有効です。

戻る

Blob - blob としてのデータ。


getBandings()

このスプレッドシート内のすべてのバンドを返します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets an array of the bandings in the spreadsheet.
const bandings = ss.getBandings();

// Logs the range of the first banding in the spreadsheet to the console.
console.log(bandings[0].getRange().getA1Notation());

戻る

Banding[] - このスプレッドシートの縞模様。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getBlob()

このオブジェクト内のデータを blob として返します。

戻る

Blob - blob としてのデータ。


getColumnWidth(columnPosition)

指定された列の幅をピクセル単位で取得します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Columns start at 1
Logger.log(sheet.getColumnWidth(1));

パラメータ

名前説明
columnPositionInteger確認する列の位置。

戻る

Integer - 列の幅(ピクセル単位)

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getCurrentCell()

アクティブ シートの現在のセルを返します。現在のセルがない場合は null を返します。「 現在のセルは、Google スプレッドシートの UI でフォーカスされているセルで、濃い色でハイライト表示されます。 クリックします。現在のセルは 1 つだけです。ユーザーが 1 つ以上のセル範囲を選択すると 選択範囲のセルの 1 つが現在のセルである。

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
// Returns the current highlighted cell in the one of the active ranges.
var currentCell = sheet.getCurrentCell();

戻る

Range - 現在のセル

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataRange()

データが存在するディメンションに対応する Range を返します。

これは機能的には、A1 で制限された Range を作成するのと同等で、 (Sheet.getLastColumn()、Sheet.getLastRow())。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This represents ALL the data
var range = sheet.getDataRange();
var values = range.getValues();

// This logs the spreadsheet in CSV format with a trailing comma
for (var i = 0; i < values.length; i++) {
  var row = "";
  for (var j = 0; j < values[i].length; j++) {
    if (values[i][j]) {
      row = row + values[i][j];
    }
    row = row + ",";
  }
  Logger.log(row);
}

戻る

Range - スプレッドシート内のすべてのデータで構成される範囲

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataSourceFormulas()

データソースの数式をすべて取得します。

// Opens the spreadsheet by its ID. If you created your script from within a Google Sheets
// file, use SpreadsheetApp.getActiveSpreadsheet().
// TODO(developer): Replace the ID with your own.
const ss = SpreadsheetApp.openById('abc123456');

// Gets Sheet1 by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets an array of the data source formulas on Sheet1.
// To get an array of data source formulas for the entire spreadsheet,
// replace 'sheet' with 'ss'.
const dataSourceFormulas = sheet.getDataSourceFormulas();

// Logs the first data source formula in the array.
console.log(dataSourceFormulas[0].getFormula());

戻る

DataSourceFormula[] - データソースの数式のリスト。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataSourcePivotTables()

データソースのピボット テーブルをすべて取得します。

// Opens the spreadsheet file by its ID. If you created your script from a Google Sheets file,
// use SpreadsheetApp.getActiveSpreadsheet().
// TODO(developer): Replace the ID with your own.
const ss = SpreadsheetApp.openById('abc123456');

// Gets Sheet1 by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets an array of the data source pivot tables on Sheet1.
// To get an array of data source pivot tables for the entire
// spreadsheet, replace 'sheet' with 'ss'.
const dataSourcePivotTables = sheet.getDataSourcePivotTables();

// Logs the last time that the first pivot table in the array was refreshed.
console.log(dataSourcePivotTables[0].getStatus().getLastRefreshedTime());

戻る

DataSourcePivotTable[] - データソースのピボット テーブルのリスト。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataSourceRefreshSchedules()

このスプレッドシートの更新スケジュールを取得します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Activates BigQuery operations for the connected spreadsheet.
SpreadsheetApp.enableBigQueryExecution();

// Gets the frequency type of the first referesh schedule in the array.
const frequencyType = ss.getDataSourceRefreshSchedules()[0]
                        .getFrequency()
                        .getFrequencyType()
                        .toString();

// Logs the frequency type to the console.
console.log(frequencyType);

戻る

DataSourceRefreshSchedule[] - このスプレッドシートの更新スケジュール。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataSourceSheets()

スプレッドシート内のすべてのデータソース シートを返します。

// Turns data execution on for BigQuery data sources.
SpreadsheetApp.enableBigQueryExecution();

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets the first data source sheet in the spreadsheet.
const dataSource = ss.getDataSourceSheets()[0];

// Gets the name of the data source sheet.
console.log(dataSource.asSheet().getName());

戻る

DataSourceSheet[] - すべてのデータソース シートの配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataSourceTables()

すべてのデータソース テーブルを取得します。

// Opens the spreadsheet file by its ID. If you created your script from a Google Sheets file,
// use SpreadsheetApp.getActiveSpreadsheet().
// TODO(developer): Replace the ID with your own.
const ss = SpreadsheetApp.openById('abc123456');

// Gets Sheet1 by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets an array of data source tables on Sheet1.
// To get an array of data source tables for the entire spreadsheet,
// replace 'sheet' with 'ss'.
const dataSourceTables = sheet.getDataSourceTables();

// Logs the last completed data execution time on the first data source table.
console.log(dataSourceTables[0].getStatus().getLastExecutionTime());

戻る

DataSourceTable[] - データソース テーブルのリスト。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDataSources()

スプレッドシート内のすべてのデータソースを返します。

// Turns data execution on for BigQuery data sources.
SpreadsheetApp.enableBigQueryExecution();

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets the data sources on the spreadsheet.
const dataSources = ss.getDataSources();

// Logs the name of the first column on the first data source.
console.log(dataSources[0].getColumns()[0].getName());

戻る

DataSource[] - すべてのデータソースの配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getDeveloperMetadata()

最上位のスプレッドシートに関連付けられているデベロッパー メタデータを取得します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Adds 'Google' as a key to the spreadsheet metadata.
ss.addDeveloperMetadata('Google');

// Gets the spreadsheet's metadata.
const ssMetadata = ss.getDeveloperMetadata();

// Gets the first set of the spreadsheet's metadata and logs the key to the console.
console.log(ssMetadata[0].getKey());

戻る

DeveloperMetadata[] - この範囲に関連付けられているデベロッパー メタデータ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getEditors()

この Spreadsheet の編集者のリストを取得します。

戻る

User[] - 編集権限を持つユーザーの配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getFormUrl()

このスプレッドシートに回答を送信するフォームの URL を返します。そうでない場合は null を返します。 このスプレッドシートにはフォームが関連付けられていません。複数のフォームからこのスプレッドシートに回答を送信した場合、 返されるフォーム URL が不確定です。代わりに、シートのフォームごとに URL を関連付けて Sheet.getFormUrl() メソッドを使用して取得できます。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets the form URL from the spreadsheet.
const formUrl = ss.getFormUrl();

// Logs the form URL to the console.
console.log(formUrl);

戻る

String - このスプレッドシートに回答を配置するフォームの URL。null このスプレッドシートにはフォームが関連付けられていません。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getFrozenColumns()

固定列の数を返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

Logger.log("Number of frozen columns: %s", sheet.getFrozenColumns());

戻る

Integer - 固定列の数

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getFrozenRows()

固定行の数を返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

Logger.log("Number of frozen rows: %s", sheet.getFrozenRows());

戻る

Integer - 固定行数

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getId()

このスプレッドシートの一意の識別子を取得します。スプレッドシート ID は URL から抽出できます。 たとえば、URL 内のスプレッドシート ID は、 https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 は「abc1234567」です。

// The code below logs the ID for the active spreadsheet.
Logger.log(SpreadsheetApp.getActiveSpreadsheet().getId());

戻る

String - スプレッドシートの一意の ID(キー)です。


getImages()

シート上のグリッド上のすべての画像を返します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets Sheet1 by its name.
const sheet = ss.getSheetByName('Sheet1');

// Gets the over-the-grid images from Sheet1.
// To get the over-the-grid images from the entire spreadsheet, use ss.getImages() instead.
const images = sheet.getImages();

// For each image, logs the anchor cell in A1 notation.
for (const image of images) {
 console.log(image.getAnchorCell().getA1Notation());
}

戻る

OverGridImage[] - グリッド上の画像の配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getIterativeCalculationConvergenceThreshold()

反復計算で使用されるしきい値を返します。連続する結果の 差がこの値より小さいと、反復計算は停止します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the iterative calculation convergence threshold for the spreadsheet.
ss.setIterativeCalculationConvergenceThreshold(2);

// Logs the threshold to the console.
console.log(ss.getIterativeCalculationConvergenceThreshold());

戻る

Number - 収束しきい値。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getLastColumn()

コンテンツを含む最後の列の位置を返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This logs the value in the very last cell of this sheet
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
var lastCell = sheet.getRange(lastRow, lastColumn);
Logger.log(lastCell.getValue());

戻る

Integer - コンテンツを含むシートの最後の列

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getLastRow()

コンテンツを含む最後の行の位置を返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This logs the value in the very last cell of this sheet
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
var lastCell = sheet.getRange(lastRow, lastColumn);
Logger.log(lastCell.getValue());

戻る

Integer - コンテンツを含むシートの最後の行

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getMaxIterativeCalculationCycles()

反復計算で使用する反復処理の最大数を返します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the max iterative calculation cycles for the spreadsheet.
ss.setMaxIterativeCalculationCycles(10);

// Logs the max iterative calculation cycles to the console.
console.log(ss.getMaxIterativeCalculationCycles());

戻る

Integer - 計算の最大反復回数。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getName()

ドキュメントの名前を取得します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
Logger.log(ss.getName());

戻る

String - スプレッドシートの名前。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getNamedRanges()

このスプレッドシート内のすべての名前付き範囲を取得します。

// The code below logs the name of the first named range.
var namedRanges = SpreadsheetApp.getActiveSpreadsheet().getNamedRanges();
for (var i = 0; i < namedRanges.length; i++) {
  Logger.log(namedRanges[i].getName());
}

戻る

NamedRange[] - スプレッドシート内のすべての名前付き範囲の配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getNumSheets()

このスプレッドシート内のシート数を返します。

// The code below logs the number of sheets in the active spreadsheet.
Logger.log(SpreadsheetApp.getActiveSpreadsheet().getNumSheets());

戻る

Integer - スプレッドシート内のシート数。


getOwner()

ドキュメントのオーナーを返します。共有ドライブ内のドキュメントの場合は null を返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var owner = ss.getOwner();
Logger.log(owner.getEmail());

戻る

User - ドキュメントのオーナー。ドキュメントが共有ドライブ内にある場合は null

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getPredefinedSpreadsheetThemes()

事前定義テーマのリストを返します。

// The code below returns the list of predefined themes.
var predefinedThemesList = SpreadsheetApp.getActiveSpreadsheet()
                               .getPredefinedSpreadsheetThemes();

戻る

SpreadsheetTheme[] - 事前定義テーマのリスト。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getProtections(type)

スプレッドシート内のすべての保護されている範囲またはシートを表すオブジェクトの配列を取得します。

// Remove all range protections in the spreadsheet that the user has permission to edit.
var ss = SpreadsheetApp.getActive();
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE);
for (var i = 0; i < protections.length; i++) {
  var protection = protections[i];
  if (protection.canEdit()) {
    protection.remove();
  }
}
// Remove all sheet protections in the spreadsheet that the user has permission to edit.
var ss = SpreadsheetApp.getActive();
var protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET);
for (var i = 0; i < protections.length; i++) {
  var protection = protections[i];
  if (protection.canEdit()) {
    protection.remove();
  }
}

パラメータ

名前説明
typeProtectionType保護対象エリアのタイプ(SpreadsheetApp.ProtectionType.RANGE または SpreadsheetApp.ProtectionType.SHEET

戻る

Protection[] — スプレッドシート内のすべての保護されている範囲またはシートを表すオブジェクトの配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getRange(a1Notation)

A1 表記または R1C1 表記で指定された範囲を返します。

// Get a range A1:D4 on sheet titled "Invoices"
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getRange("Invoices!A1:D4");

// Get cell A1 on the first sheet
var sheet = ss.getSheets()[0];
var cell = sheet.getRange("A1");

パラメータ

名前説明
a1NotationString返される範囲。A1 表記または R1C1 表記で指定します。

戻る

Range - 指定されたロケーションの範囲

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getRangeByName(name)

名前付き範囲を返します。指定された名前の範囲が見つからない場合は null を返します。複数の場合 同じ範囲名を使用する場合は、追加せずにシート名を指定してください。 引用符。例: getRangeByName('TaxRates')getRangeByName('Sheet Name!TaxRates')getRangeByName('"Sheet Name"!TaxRates') は不可。

// Log the number of columns for the range named 'TaxRates' in the active spreadsheet.
var range = SpreadsheetApp.getActiveSpreadsheet().getRangeByName('TaxRates');
if (range != null) {
  Logger.log(range.getNumColumns());
}

パラメータ

名前説明
nameString取得する範囲の名前。

戻る

Range — 指定した名前のセルの範囲。


getRangeList(a1Notations)

指定された同じシートの範囲を表す RangeList コレクションを返します。 A1 表記または R1C1 表記の空でないリストで表します。

// Get a list of ranges A1:D4, F1:H4.
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var rangeList  = sheet.getRangeList(['A1:D4', 'F1:H4']);

パラメータ

名前説明
a1NotationsString[]返される範囲のリスト。A1 表記または R1C1 表記で指定します。

戻る

RangeList - 指定されたロケーションの範囲リスト

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getRecalculationInterval()

このスプレッドシートの計算間隔を返します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Logs the calculation interval for the spreadsheet to the console.
console.log(ss.getRecalculationInterval().toString());

戻る

RecalculationInterval - このスプレッドシートの計算間隔です。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getRowHeight(rowPosition)

指定された行の高さをピクセル単位で取得します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Rows start at 1
Logger.log(sheet.getRowHeight(1));

パラメータ

名前説明
rowPositionInteger確認する行の位置。

戻る

Integer - 行の高さ(ピクセル単位)

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSelection()

スプレッドシート内の現在の Selection を返します。

var selection = SpreadsheetApp.getActiveSpreadsheet().getSelection();
var currentCell = selection.getCurrentCell();

戻る

Selection - 現在の選択

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSheetByName(name)

指定した名前のシートを返します。

同じ名前のシートが複数ある場合は、左端のシートが返されます。次の場合は null を返します。 指定した名前のシートがありません。

// The code below logs the index of a sheet named "Expenses"
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Expenses");
if (sheet != null) {
  Logger.log(sheet.getIndex());
}

パラメータ

名前説明
nameString取得するシートの名前。

戻る

Sheet - 指定した名前のシート。


getSheetId()

このオブジェクトによって表されるシートの ID を返します。

スプレッドシートに固有のシートの ID です。ID は単調で、 シートの位置に関係なく、シートの作成時に割り当てられた増加する整数。この Sheet インスタンスではなく gridId パラメータを受け取る Range.copyFormatToRange(gridId, column, columnEnd, row, rowEnd) などのメソッドと組み合わせて使用すると便利です。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

Logger.log(sheet.getSheetId());

戻る

Integer - スプレッドシートに固有のシートの ID

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSheetName()

シート名を返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

Logger.log(sheet.getSheetName());

戻る

String - シートの名前

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSheetValues(startRow, startColumn, numRows, numColumns)

指定された座標を始点とする、この範囲の値の長方形のグリッドを返します。A -1 最後の行または列を取得することと同等です。 スプレッドシート内のデータを検索できます。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// The two samples below produce the same output
var values = sheet.getSheetValues(1, 1, 3, 3);
Logger.log(values);

var range = sheet.getRange(1, 1, 3, 3);
values = range.getValues();
Logger.log(values);

パラメータ

名前説明
startRowInteger開始行の位置。
startColumnInteger開始列の位置。
numRowsInteger値を返す行数です。
numColumnsInteger値を返す列の数。

戻る

Object[][] - 値の 2 次元配列

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSheets()

このスプレッドシート内のすべてのシートを取得します。

// The code below logs the name of the second sheet
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets();
if (sheets.length > 1) {
  Logger.log(sheets[1].getName());
}

戻る

Sheet[] - スプレッドシート内のすべてのシートの配列。


getSpreadsheetLocale()

スプレッドシートの言語 / 地域を取得します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets the spreadsheet locale.
const ssLocale = ss.getSpreadsheetLocale();

// Logs the locale to the console.
console.log(ssLocale);

戻る

String - スプレッドシートの言語 / 地域。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSpreadsheetTheme()

スプレッドシートの現在のテーマを返します。テーマが適用されていない場合は null を返します。

// The code below returns the current theme of the spreadsheet.
var currentTheme = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetTheme();

戻る

SpreadsheetTheme - 現在適用されているテーマ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getSpreadsheetTimeZone()

スプレッドシートのタイムゾーンを取得します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the time zone of the spreadsheet.
ss.setSpreadsheetTimeZone('America/New_York');

// Gets the time zone of the spreadsheet.
const ssTimeZone = ss.getSpreadsheetTimeZone();

// Logs the time zone to the console.
console.log(ssTimeZone);

戻る

String - 「long」の形式で指定されるタイムゾーン(たとえば、リストされている「America/New_York」 Joda.org)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getUrl()

指定したスプレッドシートの URL を返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
Logger.log(ss.getUrl());

戻る

String - 指定したスプレッドシートの URL。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

getViewers()

この Spreadsheet の閲覧者とコメント投稿者のリストを取得します。

戻る

User[] - 閲覧権限またはコメント権限を持つユーザーの配列。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

hideColumn(column)

指定された範囲内の列を非表示にします。

let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheets()[0];

// This hides the first column
let range = sheet.getRange("A1");
sheet.hideColumn(range);

// This hides the first 3 columns
let range = sheet.getRange("A:C");
sheet.hideColumn(range);

パラメータ

名前説明
columnRange非表示にする列の範囲。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

hideRow(row)

指定した範囲の行を非表示にします。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This hides the first row
var range = sheet.getRange("A1");
sheet.hideRow(range);

パラメータ

名前説明
rowRange非表示にする行範囲。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertColumnAfter(afterPosition)

指定された列位置の後に列を挿入します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This inserts a column after the first column position
sheet.insertColumnAfter(1);

パラメータ

名前説明
afterPositionInteger新しい列を追加する列。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertColumnBefore(beforePosition)

指定された列位置の前に列を挿入します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This inserts a column in the first column position
sheet.insertColumnBefore(1);

パラメータ

名前説明
beforePositionInteger新しい列を追加する前の列。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertColumnsAfter(afterPosition, howMany)

指定された列の位置の後に、指定された数の列を挿入します。

let ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheets()[0];

// Inserts two columns after the first column on the first sheet of the spreadsheet.
sheet.insertColumnsAfter(1,2);

パラメータ

名前説明
afterPositionInteger新しい列を追加する列。
howManyInteger挿入する列の数。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertColumnsBefore(beforePosition, howMany)

指定された列位置の前に複数の列を挿入します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This inserts five columns before the first column
sheet.insertColumnsBefore(1, 5);

パラメータ

名前説明
beforePositionInteger新しい列を追加する前の列。
howManyInteger挿入する列の数。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertDataSourceSheet(spec)

スプレッドシートに新しい DataSourceSheet を挿入し、データの実行を開始します。たとえば、 新しいシートがアクティブ シートになります。

データソース タイプが有効になっていない場合、例外をスローします。SpreadsheetApp#enable...Execution() メソッドを使用して、特定のデータソースのデータ実行を有効にする あります。

// Activates BigQuery operations.
SpreadsheetApp.enableBigQueryExecution();

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Builds a data source specification.
// TODO (developer): Update the project ID to your own Google Cloud project ID.
const dataSourceSpec = SpreadsheetApp.newDataSourceSpec()
 .asBigQuery()
 .setProjectId('project-id-1')
 .setTableProjectId('bigquery-public-data')
 .setDatasetId('ncaa_basketball')
 .setTableId('mbb_historical_teams_games')
 .build();

// Adds the data source and its data to the spreadsheet.
ss.insertDataSourceSheet(dataSourceSpec);

パラメータ

名前説明
specDataSourceSpec挿入に使用するデータソース仕様。

戻る

DataSourceSheet - 新しいデータソース シート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertImage(blobSource, column, row)

ドキュメントの指定された行と列の Spreadsheet を画像として挿入します。イメージ サイズが blob の内容から取得されます。サポートされる blob の最大サイズは 2 MB です。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var blob = Utilities.newBlob(binaryData, 'image/png', 'MyImageName');
sheet.insertImage(blob, 1, 1);

パラメータ

名前説明
blobSourceBlobSource画像コンテンツ、MIME タイプ、名前(省略可)を含む blob。
columnInteger列の位置。
rowInteger行の位置。

戻る

OverGridImage - 挿入される画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertImage(blobSource, column, row, offsetX, offsetY)

ドキュメントの指定された行と列に Spreadsheet を画像として挿入します。 ピクセル オフセット。画像サイズは blob コンテンツから取得されます。サポートされている blob の最大値 サイズは 2MB です。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var blob = Utilities.newBlob(binaryData, 'image/png', 'MyImageName');
sheet.insertImage(blob, 1, 1, 10, 10);

パラメータ

名前説明
blobSourceBlobSource画像コンテンツ、MIME タイプ、名前(省略可)を含む blob。
columnInteger列の位置。
rowInteger行の位置。
offsetXIntegerセルの隅からの水平オフセット(ピクセル単位)。
offsetYIntegerセルの隅からの垂直オフセット(ピクセル単位)。

戻る

OverGridImage - 挿入される画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertImage(url, column, row)

ドキュメントの指定された行と列に画像を挿入します。

指定する URL は一般公開されている必要があります。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

sheet.insertImage("https://www.google.com/images/srpr/logo3w.png", 1, 1);

パラメータ

名前説明
urlString画像の URL です。
columnIntegerグリッドの列の位置。
rowIntegerグリッド行の位置。

戻る

OverGridImage - 挿入される画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertImage(url, column, row, offsetX, offsetY)

ドキュメントの指定された行と列に、ピクセル オフセットで画像を挿入します。

指定する URL は一般公開されている必要があります。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

sheet.insertImage("https://www.google.com/images/srpr/logo3w.png", 1, 1, 10, 10);

パラメータ

名前説明
urlString画像の URL。
columnInteger列の位置。
rowInteger行の位置。
offsetXIntegerセルの隅からの水平オフセット(ピクセル単位)。
offsetYIntegerセルの隅からの垂直オフセット(ピクセル単位)。

戻る

OverGridImage - 挿入された画像。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertRowAfter(afterPosition)

指定された行位置の後に行を挿入します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This inserts a row after the first row position
sheet.insertRowAfter(1);

パラメータ

名前説明
afterPositionInteger新しい行を追加する後の行。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertRowBefore(beforePosition)

指定された行位置の前に行を挿入します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This inserts a row before the first row position
sheet.insertRowBefore(1);

パラメータ

名前説明
beforePositionInteger新しい行を追加する前の行。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertRowsAfter(afterPosition, howMany)

指定された行位置の後に複数の行を挿入します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This inserts five rows after the first row
sheet.insertRowsAfter(1, 5);

パラメータ

名前説明
afterPositionInteger新しい行を追加する後の行。
howManyInteger挿入する行数。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertRowsBefore(beforePosition, howMany)

指定された行の位置の前に複数の行を挿入します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This inserts five rows before the first row
sheet.insertRowsBefore(1, 5);

パラメータ

名前説明
beforePositionInteger新しい行を追加する前の行。
howManyInteger挿入する行数。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet()

デフォルトのシート名を使用して、スプレッドシートに新しいシートを挿入します。新しいシートは クリックします。

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.insertSheet();

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet(sheetIndex)

スプレッドシートの指定されたインデックスに新しいシートを挿入します。新しいシートがアクティブになります できます。

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.insertSheet(1);

パラメータ

名前説明
sheetIndexInteger新しく作成されたシートのインデックス。シートを 1 番目として挿入するには、 0 に設定します。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet(sheetIndex, options)

スプレッドシートの指定されたインデックスに新しいシートを挿入します。必要に応じて高度なオプションを使用します。 渡します。新しいシートがアクティブ シートになります。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var templateSheet = ss.getSheetByName('Sales');
ss.insertSheet(1, {template: templateSheet});

パラメータ

名前説明
sheetIndexInteger新しく作成されたシートのインデックス。シートを 1 番目として挿入するには、 0 に設定します。
optionsObject省略可能な JavaScript 詳細引数。

拡張パラメータ

名前説明
templateSheetテンプレート シート オブジェクトのすべてのデータが クリックします。シート テンプレートは、Spreadsheet オブジェクトのいずれかのシートである必要があります。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet(options)

デフォルトのシート名とオプションの詳細設定を使用して、新しいシートをスプレッドシートに挿入します 渡します。新しいシートがアクティブ シートになります。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var templateSheet = ss.getSheetByName('Sales');
ss.insertSheet({template: templateSheet});

パラメータ

名前説明
optionsObject省略可能な JavaScript 詳細引数(下記を参照)。

拡張パラメータ

名前説明
templateSheetテンプレート シート オブジェクトのすべてのデータが クリックします。シート テンプレートは、この Spreadsheet オブジェクトのシートのいずれかである必要があります。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet(sheetName)

指定した名前の新しいシートをスプレッドシートに挿入します。新しいシートがアクティブになります できます。

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.insertSheet('My New Sheet');

パラメータ

名前説明
sheetNameString新しいシートの名前。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet(sheetName, sheetIndex)

スプレッドシートの指定されたインデックスに、指定された名前で新しいシートを挿入します。新しいシート アクティブシートになります

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.insertSheet('My New Sheet', 1);

パラメータ

名前説明
sheetNameString新しいシートの名前。
sheetIndexInteger新しく作成されたシートのインデックス。シートを 1 番目として挿入するには、 0 に設定します。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet(sheetName, sheetIndex, options)

スプレッドシートの指定されたインデックスに指定された名前で新しいシートを挿入し、 高度な引数。新しいシートがアクティブ シートになります。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var templateSheet = ss.getSheetByName('Sales');
ss.insertSheet('My New Sheet', 1, {template: templateSheet});

パラメータ

名前説明
sheetNameString新しいシートの名前。
sheetIndexInteger新しく挿入されたシートのインデックス。シートを 1 番目として挿入するには、 0 に設定します。
optionsObject省略可能な JavaScript 詳細引数。

拡張パラメータ

名前説明
templateSheetテンプレート シート オブジェクトのすべてのデータが クリックします。シート テンプレートは、Spreadsheet オブジェクトのいずれかのシートである必要があります。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheet(sheetName, options)

指定した名前の新しいシートをスプレッドシートに挿入します。必要に応じて高度なオプションを使用します。 渡します。新しいシートがアクティブ シートになります。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var templateSheet = ss.getSheetByName('Sales');
ss.insertSheet('My New Sheet', {template: templateSheet});

パラメータ

名前説明
sheetNameString新しいシートの名前。
optionsObject省略可能な JavaScript 詳細引数。

拡張パラメータ

名前説明
templateSheetテンプレート シート オブジェクトのすべてのデータが クリックします。シート テンプレートは、Spreadsheet オブジェクトのいずれかのシートである必要があります。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

insertSheetWithDataSourceTable(spec)

スプレッドシートに新しいシートを挿入し、そのシート全体に DataSourceTable を作成します。 スプレッドシート全体を実行し、データの実行を開始します。側として 新しいシートがアクティブ シートになります。

データソース タイプが有効になっていない場合、例外をスローします。SpreadsheetApp#enable...Execution() メソッドを使用して、特定のデータソースのデータ実行を有効にする あります。

// Activates BigQuery operations.
SpreadsheetApp.enableBigQueryExecution();

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Adds a sheet and sets cell A1 as the parameter cell.
const parameterCell = ss.insertSheet('parameterSheet').getRange('A1');

// Sets the value of the parameter cell to 'Duke'.
parameterCell.setValue('Duke');

const query = 'select * from `bigquery-public-data`.`ncaa_basketball`.' +
  '`mbb_historical_tournament_games` WHERE win_school_ncaa = @SCHOOL';

// Adds a data source with a query parameter.
// TODO(developer): Update the project ID to your own Google Cloud project ID.
const dataSourceSpec = SpreadsheetApp.newDataSourceSpec()
 .asBigQuery()
 .setProjectId('project-id-1')
 .setRawQuery(query)
 .setParameterFromCell('SCHOOL', 'parameterSheet!A1')
 .build();

// Adds sheets for the data source and data source table to the spreadsheet.
ss.insertSheetWithDataSourceTable(dataSourceSpec);

パラメータ

名前説明
specDataSourceSpec挿入に使用するデータソース仕様。

戻る

Sheet - 新しいシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

isColumnHiddenByUser(columnPosition)

指定された列がユーザーによって非表示かどうかを返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Columns start at 1
Logger.log(sheet.isColumnHiddenByUser(1));

パラメータ

名前説明
columnPositionInteger確認する列の位置。

戻る

Boolean - 列が非表示の場合は true、それ以外の場合は false

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

isIterativeCalculationEnabled()

このスプレッドシートで反復計算が有効になっているかどうかを返します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Activates iterative calculation on the spreadsheet.
ss.setIterativeCalculationEnabled(true);

// Logs whether iterative calculation is activated for the spreadsheet.
console.log(ss.isIterativeCalculationEnabled());

戻る

Boolean - 反復計算が有効になっている場合は true、それ以外の場合は false

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

isRowHiddenByFilter(rowPosition)

指定した行が(フィルタ表示ではなく)フィルタによって非表示になっているかどうかを返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Rows start at 1
Logger.log(sheet.isRowHiddenByFilter(1));

パラメータ

名前説明
rowPositionInteger確認する行の位置。

戻る

Boolean - 行が非表示の場合は true、それ以外の場合は false

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

isRowHiddenByUser(rowPosition)

指定した行がユーザーによって非表示かどうかを返します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Rows start at 1
Logger.log(sheet.isRowHiddenByUser(1));

パラメータ

名前説明
rowPositionInteger確認する行の位置。

戻る

Boolean - 行が非表示の場合は true、それ以外の場合は false

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

moveActiveSheet(pos)

アクティブなシートをシートリストの指定された位置に移動します。次の場合に例外をスローします。 位置が負であるか、シート数を超えています。

// This example assumes that there are 2 sheets in the current
// active spreadsheet: one named "first" in position 1 and another named "second"
// in position 2.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// Gets the "first" sheet and activates it.
var sheet = spreadsheet.getSheetByName("first").activate();

// Logs 'Current index of sheet: 1'
console.log("Current index of sheet: %s", sheet.getIndex());

spreadsheet.moveActiveSheet(2);

// Logs 'New index of sheet: 2'
console.log("New index of sheet: %s", sheet.getIndex());

パラメータ

名前説明
posIntegerシートリスト内のアクティブなシートの移動先の 1-Index の位置。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

moveChartToObjectSheet(chart)

新しい SheetType.OBJECT シートを作成し、指定されたグラフをそのシートに移動します。グラフが すでに別のシートに追加されている場合は、新しいシートを作成せずにそのシートが返されます。

var sheet = SpreadsheetApp.getActiveSheet();
var chart = sheet.newChart().setPosition(1, 1, 0, 0).build();
sheet.insertChart(chart);
var objectSheet = SpreadsheetApp.getActive().moveChartToObjectSheet(chart);

パラメータ

名前説明
chartEmbeddedChart移動するグラフ。

戻る

Sheet - グラフが表示されているシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

refreshAllDataSources()

サポートされているすべてのデータソースとそれらにリンクされたデータソース オブジェクトを更新します(無効なものはスキップします) 作成します。

SpreadsheetApp#enable...Execution() メソッドを使用してデータ実行を有効にする 指定することもできます。

// Activates BigQuery operations.
SpreadsheetApp.enableBigQueryExecution();

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Gets the first data source sheet on the spreadsheet.
const dataSheet = ss.getDataSourceSheets()[0];

// Refreshes all data sources on the spreadsheet.
ss.refreshAllDataSources();

// Logs the last refreshed time of the first data source sheet.
console.log(`Last refresh time: ${dataSheet.getStatus().getLastRefreshedTime()}`);

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

removeEditor(emailAddress)

Spreadsheet の編集者のリストから指定したユーザーを削除します。この方法では 次のクラスのユーザーに属している場合、Spreadsheet へのアクセスをブロックします。 (たとえば、Spreadsheet がユーザーの組織全体で共有されている場合、 Spreadsheet が、ユーザーがアクセスできる共有ドライブ内にあるかどうかも確認できます。

ドライブのファイルの場合、閲覧者のリストからユーザーが削除されます。

パラメータ

名前説明
emailAddressString削除するユーザーのメールアドレス。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

removeEditor(user)

Spreadsheet の編集者のリストから指定したユーザーを削除します。この方法では 次のクラスのユーザーに属している場合、Spreadsheet へのアクセスをブロックします。 (たとえば、Spreadsheet がユーザーの組織全体で共有されている場合、 Spreadsheet が、ユーザーがアクセスできる共有ドライブ内にあるかどうかも確認できます。

ドライブのファイルの場合、閲覧者のリストからユーザーが削除されます。

パラメータ

名前説明
userUser削除するユーザーの表現。

戻る

Spreadsheet - この Spreadsheet(チェーン用)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

removeMenu(name)

addMenu(name, subMenus) が追加したメニューを削除します。name 引数 対応する addMenu(name, subMenus) の呼び出しと同じ値にする必要があります。

// The onOpen function is executed automatically every time a Spreadsheet is loaded
function onOpen() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.addMenu("badMenu", [{name: "remove bad menu", functionName: "removeBadMenu"},
                                       {name: "foo", functionName: "foo"}]);
}
function removeBadMenu() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.removeMenu("badMenu");  // name must match the name used when added the menu
}
function foo(){
// Do nothing
}

パラメータ

名前説明
nameString削除するメニューの名前。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

removeNamedRange(name)

指定された名前の名前付き範囲を削除します。指定された名前の範囲がない場合、例外をスローします。 スプレッドシートにあります。

// The code below creates a new named range "foo", and then remove it.
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setNamedRange("foo", ss.getActiveRange());
ss.removeNamedRange("foo");

パラメータ

名前説明
nameString範囲名。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

removeViewer(emailAddress)

Spreadsheet の閲覧者と閲覧者(コメント可)のリストから指定したユーザーを削除します。この ユーザーが編集者であり、閲覧者でもコメント投稿者でもない場合、メソッドは効果がありません。この方法でも は、所属するユーザーが次のクラスのユーザーに属している場合でも、Spreadsheet へのアクセスをブロックしません。 一般的なアクセス権を持っている(たとえば、Spreadsheet がユーザーの または、Spreadsheet が、ユーザーがアクセスできる共有ドライブ内にあるかどうかを指定できます。

ドライブのファイルの場合は、編集者のリストからユーザーが削除されます。

パラメータ

名前説明
emailAddressString削除するユーザーのメールアドレス。

戻る

Spreadsheet - このチェーン用の Spreadsheet

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

removeViewer(user)

Spreadsheet の閲覧者と閲覧者(コメント可)のリストから指定したユーザーを削除します。この メソッドは、ユーザーが編集者であって閲覧者ではない場合は機能しません。この方法では 一般的なユーザー クラスに属するユーザーは、Spreadsheet にアクセスできない たとえば、Spreadsheet がユーザーのドメイン全体と共有されている場合、または Spreadsheet が、ユーザーがアクセスできる共有ドライブ内にあるかどうか。

ドライブのファイルの場合は、編集者のリストからユーザーが削除されます。

パラメータ

名前説明
userUser削除するユーザーの表現。

戻る

Spreadsheet - このチェーン用の Spreadsheet

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

rename(newName)

ドキュメントの名前を変更します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.rename("This is the new name");

パラメータ

名前説明
newNameStringドキュメントの新しい名前。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

renameActiveSheet(newName)

現在アクティブなシートを、指定した新しい名前に変更します。

// The code below renames the active sheet to "Hello world"
SpreadsheetApp.getActiveSpreadsheet().renameActiveSheet("Hello world");

パラメータ

名前説明
newNameString現在アクティブなシートの新しい名前。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

resetSpreadsheetTheme()

適用したテーマを削除し、スプレッドシートのデフォルトのテーマを設定します。

// The code below applies default theme on the spreadsheet.
SpreadsheetApp.getActiveSpreadsheet().resetSpreadsheetTheme();

戻る

SpreadsheetTheme - デフォルトのテーマ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveRange(range)

指定した範囲をアクティブ シートの active range として設定します。 範囲内の左上のセルを current cell として指定します。

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getRange('A1:D4');
sheet.setActiveRange(range);

var selection = sheet.getSelection();
// Current cell: A1
var currentCell = selection.getCurrentCell();
// Active Range: A1:D4
var activeRange = selection.getActiveRange();

パラメータ

名前説明
rangeRange有効範囲として設定する範囲です。

戻る

Range - 新しくアクティブになった範囲

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveRangeList(rangeList)

指定された範囲リストを active ranges ブロックとして設定します。 クリックします。リストの最後の範囲が active range として設定されます。

var sheet = SpreadsheetApp.getActiveSheet();
var rangeList = sheet.getRangeList(['D4', 'B2:C4']);
sheet.setActiveRangeList(rangeList);

var selection = sheet.getSelection();
// Current cell: B2
var currentCell = selection.getCurrentCell();
// Active range: B2:C4
var activeRange = selection.getActiveRange();
// Active range list: [D4, B2:C4]
var activeRangeList = selection.getActiveRangeList();

パラメータ

名前説明
rangeListRangeList選択する範囲のリスト。

戻る

RangeList - 新しく選択された範囲のリスト

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveSelection(range)

このシートの有効な選択領域を設定します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

var range = sheet.getRange("A1:D4");
sheet.setActiveSelection(range);

パラメータ

名前説明
rangeRangeアクティブな選択として設定する範囲です。

戻る

Range - 新しくアクティブになった範囲

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveSelection(a1Notation)

A1 表記または R1C1 表記で指定されたとおりに、アクティブな選択を設定します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

sheet.setActiveSelection("A1:D4");

パラメータ

名前説明
a1NotationStringアクティブとして設定する範囲。A1 表記または R1C1 表記で指定します。

戻る

Range - 新しくアクティブになった範囲

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveSheet(sheet)

指定したシートを、スプレッドシート内のアクティブなシートに設定します。Google スプレッドシートの UI が表示されている 選択されたシートが別のスプレッドシートに属している場合、この限りではありません。

// The code below makes the first sheet active in the active spreadsheet.
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
spreadsheet.setActiveSheet(spreadsheet.getSheets()[0]);

パラメータ

名前説明
sheetSheetアクティブ シートとして設定するシート。

戻る

Sheet - アクティブなシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setActiveSheet(sheet, restoreSelection)

指定したシートをスプレッドシート内のアクティブなシートに設定します。復元するオプションも用意されています。 そのシート内の最新の選択項目が表示されます。選択したシートが Google スプレッドシートの UI に表示されます。 シートは別のスプレッドシートに属しています。

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var firstSheet = spreadsheet.getSheets()[0];
var secondSheet = spreadsheet.getSheets()[1];
// Set the first sheet as the active sheet and select the range D4:F4.
spreadsheet.setActiveSheet(firstSheet).getRange('D4:F4').activate();

// Switch to the second sheet to do some work.
spreadsheet.setActiveSheet(secondSheet);
// Switch back to first sheet, and restore its selection.
spreadsheet.setActiveSheet(firstSheet, true);

// The selection of first sheet is restored, and it logs D4:F4
var range = spreadsheet.getActiveSheet().getSelection().getActiveRange();
Logger.log(range.getA1Notation());

パラメータ

名前説明
sheetSheet新しいアクティブ シート。
restoreSelectionBooleanTf true、新しいアクティブ シートの最新の選択 新しいシートがアクティブになると、再度選択されます。false の場合、新しいシート 有効になります。

戻る

Sheet - 新しいアクティブ シート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setColumnWidth(columnPosition, width)

指定された列の幅をピクセル単位で設定します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Sets the first column to a width of 200 pixels
sheet.setColumnWidth(1, 200);

パラメータ

名前説明
columnPositionInteger設定する列の位置。
widthInteger設定する幅(ピクセル単位)。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setCurrentCell(cell)

指定されたセルを current cell として設定します。

指定したセルが、すでに選択されている範囲内に存在する場合、その範囲は 現在のセルとして選択されます。

指定したセルが選択した範囲にない場合は、既存の選択内容がすべて適用されます。 削除され、そのセルが現在のセルとそのアクティブ範囲になります。

注: 指定する Range は、1 つのセルで構成する必要があります。そうでない場合は、次のエラーがスローされます。 発生します。

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var cell = sheet.getRange('B5');
sheet.setCurrentCell(cell);

var selection = sheet.getSelection();
// Current cell: B5
var currentCell = selection.getCurrentCell();

パラメータ

名前説明
cellRange現在のセルとして設定するセル。

戻る

Range - 新しく設定された現在のセル

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setFrozenColumns(columns)

指定された列数を固定します。ゼロの場合、どの列も固定されません。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Freezes the first column
sheet.setFrozenColumns(1);

パラメータ

名前説明
columnsInteger固定する列の数。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setFrozenRows(rows)

指定された行数を固定します。ゼロの場合、どの行も固定されません。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Freezes the first row
sheet.setFrozenRows(1);

パラメータ

名前説明
rowsInteger固定する行数です。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setIterativeCalculationConvergenceThreshold(minThreshold)

反復計算の最小しきい値を設定します。連続する結果の 差がこの値より小さいと、反復計算は停止します。この値は デフォルトは 0.05 です。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the iterative calculation convergence threshold for the spreadsheet.
ss.setIterativeCalculationConvergenceThreshold(2);

// Logs the threshold to the console.
console.log(ss.getIterativeCalculationConvergenceThreshold());

パラメータ

名前説明
minThresholdNumber最小収束しきい値(負でない値)。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setIterativeCalculationEnabled(isEnabled)

このスプレッドシートで反復計算を有効にするかどうかを設定します。レプリカの最大数が 計算サイクルと収束しきい値が、事前に 50 と 0.05 になります。いずれかが以前に設定されている場合は、 保持できます。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Activates iterative calculation on the spreadsheet.
ss.setIterativeCalculationEnabled(true);

// Logs whether iterative calculation is activated for the spreadsheet.
console.log(ss.isIterativeCalculationEnabled());

パラメータ

名前説明
isEnabledBoolean反復計算を有効にする場合は truefalse できません。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setMaxIterativeCalculationCycles(maxIterations)

反復処理の際に実行する計算の最大反復回数を設定します 計算します。この値は 1 ~ 10,000 の範囲で指定する必要があります。デフォルト値は 50 です。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the max iterative calculation cycles for the spreadsheet.
ss.setMaxIterativeCalculationCycles(10);

// Logs the max iterative calculation cycles to the console.
console.log(ss.getMaxIterativeCalculationCycles());

パラメータ

名前説明
maxIterationsInteger計算の最大反復回数(1 ~ 10,000)。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setNamedRange(name, range)

範囲に名前を付けます。

// The code below creates a new named range "TaxRates" in the active spreadsheet
var ss = SpreadsheetApp.getActiveSpreadsheet();
ss.setNamedRange("TaxRates", SpreadsheetApp.getActiveRange());

パラメータ

名前説明
nameString範囲に付ける名前。
rangeRange範囲の仕様。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setRecalculationInterval(recalculationInterval)

このスプレッドシートを再計算する頻度を設定します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets file, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the  calculation interval for the spreadsheet to 'ON_CHANGE'.
const interval = ss.setRecalculationInterval(SpreadsheetApp.RecalculationInterval.ON_CHANGE);

// Logs the calculation interval to the console.
console.log(interval);

パラメータ

名前説明
recalculationIntervalRecalculationInterval新しい再計算間隔。

戻る

Spreadsheet - チェーン用のスプレッドシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setRowHeight(rowPosition, height)

指定された行の行の高さをピクセル単位で設定します。デフォルトでは、セルのコンテンツに合わせて行が大きくなります。条件 行を指定の高さにするには、Sheet.setRowHeightsForced(startRow, numRows, height) を使用します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Sets the first row to a height of 200 pixels
sheet.setRowHeight(1, 200);

パラメータ

名前説明
rowPositionInteger変更する行の位置。
heightInteger設定する高さ(ピクセル単位)。

戻る

Sheet - メソッド チェーンに役立つシート。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setSpreadsheetLocale(locale)

スプレッドシートの言語 / 地域を設定します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the spreadsheet locale.
ss.setSpreadsheetLocale('fr');

// Gets the spreadsheet locale.
const ssLocale = ss.getSpreadsheetLocale();

// Logs the locale to the console.
console.log(ssLocale);

パラメータ

名前説明
localeString使用する言語 / 地域コード(「en」、「fr」、「en_US」など)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setSpreadsheetTheme(theme)

スプレッドシートにテーマを設定します。

var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
// The code below sets the second predefined theme as the current theme of the spreadsheet.
var predefinedThemesList = spreadsheet.getPredefinedSpreadsheetThemes();
spreadsheet.setSpreadsheetTheme(predefinedThemesList[1]);

パラメータ

名前説明
themeSpreadsheetTheme適用するテーマ。

戻る

SpreadsheetTheme - 現在の新しいテーマ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

setSpreadsheetTimeZone(timezone)

スプレッドシートのタイムゾーンを設定します。

// Opens the spreadsheet file by its URL. If you created your script from within a
// Google Sheets spreadsheet, you can use SpreadsheetApp.getActiveSpreadsheet() instead.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit');

// Sets the time zone of the spreadsheet.
ss.setSpreadsheetTimeZone('America/New_York');

// Gets the time zone of the spreadsheet.
const ssTimeZone = ss.getSpreadsheetTimeZone();

// Logs the time zone to the console.
console.log(ssTimeZone);

パラメータ

名前説明
timezoneString"long" で指定されたタイムゾーン(例: 「America/New_York」、 Joda.org で確認)できます。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

show(userInterface)

ユーザーのブラウザの中央に配置されたダイアログに、カスタム ユーザー インターフェース コンポーネントを表示します。 表示されなくなります。サーバーサイド スクリプトの実行は、一時停止されません。外部サーバーとの通信は ユーザー インターフェース コンポーネントはサーバー側への非同期コールバックを 使用します。

サーバーサイド スクリプトによって以前に表示されたダイアログがまだ閉じられていない場合、 既存のダイアログは、新しくリクエストされたダイアログのユーザー インターフェースに置き換えられます。

次のコード スニペットは、シンプルな HtmlService アプリケーションをダイアログに表示します。 指定したタイトル、高さ、幅:

var htmlApp = HtmlService
    .createHtmlOutput('<p>A change of speed, a change of style...</p>')
    .setTitle('My HtmlService Application')
    .setWidth(250)
    .setHeight(300);

SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);

// The script resumes execution immediately after showing the dialog.

パラメータ

名前説明
userInterfaceObjectHtmlOutput

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/script.container.ui

sort(columnPosition)

シートを列を基準に昇順で並べ替えます。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Sorts the sheet by the first column, ascending
sheet.sort(1);

パラメータ

名前説明
columnPositionInteger並べ替えの基準となる列です。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

sort(columnPosition, ascending)

シートを列で並べ替えます。パラメータを受け取り、昇順または降順を指定します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// Sorts the sheet by the first column, descending
sheet.sort(1, false);

パラメータ

名前説明
columnPositionInteger並べ替えの基準となる列です。
ascendingBoolean昇順の場合は true、降順の場合は false です。

戻る

Sheet - メソッド チェーンに役立つシート

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

toast(msg)

指定されたメッセージで、スプレッドシートの右下にポップアップ ウィンドウを表示します。

// Show a popup with the message "Task started".
SpreadsheetApp.getActiveSpreadsheet().toast('Task started');

パラメータ

名前説明
msgStringトーストに表示されるメッセージ。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

toast(msg, title)

スプレッドシートの右下に、指定されたメッセージとポップアップ ウィンドウを表示する できます。

// Show a popup with the title "Status" and the message "Task started".
SpreadsheetApp.getActiveSpreadsheet().toast('Task started', 'Status');

パラメータ

名前説明
msgStringトーストに表示されるメッセージ。
titleStringトーストのタイトル(省略可)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

toast(msg, title, timeoutSeconds)

指定されたタイトルのスプレッドシートの右下にポップアップ ウィンドウを表示する メッセージが一定時間表示されます。

// Show a 3-second popup with the title "Status" and the message "Task started".
SpreadsheetApp.getActiveSpreadsheet().toast('Task started', 'Status', 3);

パラメータ

名前説明
msgStringトーストに表示されるメッセージ。
titleStringトーストのタイトル(省略可)。
timeoutSecondsNumberタイムアウト(秒単位)。null の場合、トーストはデフォルトで 5 秒に設定されます。 負の場合、トーストは閉じられるまで保持されます。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

unhideColumn(column)

指定された範囲の列を再表示します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This unhides the first column if it was previously hidden
var range = sheet.getRange("A1");
sheet.unhideColumn(range);

パラメータ

名前説明
columnRange再表示する範囲(非表示の場合)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

unhideRow(row)

指定した範囲の行を再表示します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];

// This unhides the first row if it was previously hidden
var range = sheet.getRange("A1");
sheet.unhideRow(range);

パラメータ

名前説明
rowRange再表示する範囲(非表示の場合)。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

updateMenu(name, subMenus)

addMenu(name, subMenus) が追加したメニューを更新します。addMenu(name, subMenus) とまったく同じように機能します。

var ss = SpreadsheetApp.getActiveSpreadsheet();
var menuEntries = [];
menuEntries.push({name: "Lone Menu Entry", functionName: "function1"});
ss.updateMenu("addMenuExample", menuEntries);

パラメータ

名前説明
nameString更新するメニューの名前。
subMenusObject[]name パラメータと functionName パラメータを含む JavaScript マップの配列。付属のライブラリ( Library.libFunction1 など)の関数を使用できます。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

waitForAllDataExecutionsCompletion(timeoutInSeconds)

スプレッドシートで現在実行されているすべての実行が完了するまで待機し、次の時間が経過するとタイムアウトします。 指定されています。タイミング時に実行が完了していない場合、例外をスローします。 データの実行はキャンセルされません。

パラメータ

名前説明
timeoutInSecondsIntegerデータの実行を待機する時間(秒単位)。上限は 300 です 秒です。

承認

このメソッドを使用するスクリプトには、次のスコープの 1 つ以上を使用した承認が必要です。

  • https://www.googleapis.com/auth/spreadsheets.currentonly
  • https://www.googleapis.com/auth/spreadsheets

サポート終了のメソッド