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スプレッドシートの現在のデータ領域の下に行を追加します。
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空でない A1 表記または R1C1 表記のリストで指定された同じシート内の範囲を表す RangeList コレクションを返します。
getRecalculationInterval()RecalculationIntervalこのスプレッドシートの計算間隔を返します。
getRowHeight(rowPosition)Integer指定された行の高さをピクセル単位で取得します。
getSelection()Selectionスプレッドシートの現在の Selection を返します。
getSheetById(id)Sheet指定された ID のシートを取得します。
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指定された行位置の後に 1 行を挿入します。
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)Spreadsheet指定されたユーザーを Spreadsheet の編集者リストから削除します。
removeEditor(user)Spreadsheet指定されたユーザーを Spreadsheet の編集者リストから削除します。
removeMenu(name)voidaddMenu(name, subMenus) で追加されたメニューを削除します。
removeNamedRange(name)void指定された名前の名前付き範囲を削除します。
removeViewer(emailAddress)Spreadsheet指定されたユーザーを Spreadsheet の閲覧者とコメント投稿者のリストから削除します。
removeViewer(user)Spreadsheet指定されたユーザーを Spreadsheet の閲覧者とコメント投稿者のリストから削除します。
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() {   const ss = SpreadsheetApp.getActiveSpreadsheet();   const 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)

スプレッドシートの現在のデータ領域の下に行を追加します。セルの内容が = で始まる場合、数式として解釈されます。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

指定された列の幅をコンテンツに合わせて設定します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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 const 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)

スプレッドシートのテキスト検索ツールを作成します。このツールを使用して、スプレッドシート内のテキストを検索して置換できます。検索はスプレッドシートの最初のシートから始まります。

const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();  // Creates  a text finder. const textFinder = spreadsheet.createTextFinder('dog');  // Returns the first occurrence of 'dog' in the spreadsheet. const firstOccurrence = textFinder.findNext();  // Replaces the last found occurrence of 'dog' with 'cat' and returns the number // of occurrences replaced. const numOccurrencesReplaced = textFinder.replaceWith('cat');

パラメータ

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

戻る

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


deleteActiveSheet()

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

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

戻る

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

承認

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

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

deleteColumn(columnPosition)

指定された列位置にある列を削除します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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. const ss = SpreadsheetApp.getActive(); const 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() を使用することをおすすめします。

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

戻る

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

承認

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

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

getActiveRange()

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

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

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

戻る

Range - アクティブな範囲。

承認

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

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

関連情報


getActiveRangeList()

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

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

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

戻る

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

承認

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

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

関連情報


getActiveSheet()

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

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

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

戻る

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


getAs(contentType)

このオブジェクト内のデータを、指定されたコンテンツ タイプに変換された blob として返します。このメソッドは、ファイル名に適切な拡張子(「myfile.pdf」など)を追加します。ただし、最後のピリオドの後に続くファイル名の一部(存在する場合)は、置き換える必要がある既存の拡張子であると想定されます。その結果、「ShoppingList.12.25.2014」は「ShoppingList.12.25.pdf」になります。

コンバージョンの 1 日あたりの割り当てを確認するには、Google サービスの割り当てをご覧ください。新しく作成された 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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 つ以上のセル範囲を選択すると、選択範囲内のいずれかのセルが現在のセルになります。

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

戻る

Range - 現在のセル。

承認

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

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

getDataRange()

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

これは、A1 と(Sheet.getLastColumn(), Sheet.getLastRow())で囲まれた範囲を作成するのと機能的に同等です。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // This represents ALL the data const range = sheet.getDataRange(); const values = range.getValues();  // This logs the spreadsheet in CSV format with a trailing comma for (let i = 0; i < values.length; i++) {   let row = '';   for (let 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()

固定された列の数を返します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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()

固定された行数を返します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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 から抽出できます。たとえば、https://docs.google.com/spreadsheets/d/abc1234567/edit#gid=0 という URL のスプレッドシート ID は「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()

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // This logs the value in the very last cell of this sheet const lastRow = sheet.getLastRow(); const lastColumn = sheet.getLastColumn(); const 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()

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // This logs the value in the very last cell of this sheet const lastRow = sheet.getLastRow(); const lastColumn = sheet.getLastColumn(); const 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()

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

const 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. const namedRanges = SpreadsheetApp.getActiveSpreadsheet().getNamedRanges(); for (let 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 を返します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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. const 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. const ss = SpreadsheetApp.getActive(); const protections = ss.getProtections(SpreadsheetApp.ProtectionType.RANGE); for (let i = 0; i < protections.length; i++) {   const protection = protections[i];   if (protection.canEdit()) {     protection.remove();   } }
// Remove all sheet protections in the spreadsheet that the user has permission // to edit. const ss = SpreadsheetApp.getActive(); const protections = ss.getProtections(SpreadsheetApp.ProtectionType.SHEET); for (let i = 0; i < protections.length; i++) {   const 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" const ss = SpreadsheetApp.getActiveSpreadsheet(); const range = ss.getRange('Invoices!A1:D4');  // Get cell A1 on the first sheet const sheet = ss.getSheets()[0]; const cell = sheet.getRange('A1');

パラメータ

名前説明
a1NotationStringA1 表記または 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. const range = SpreadsheetApp.getActiveSpreadsheet().getRangeByName('TaxRates'); if (range != null) {   Logger.log(range.getNumColumns()); }

パラメータ

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

戻る

Range - 指定された名前のセル範囲。


getRangeList(a1Notations)

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

// Get a list of ranges A1:D4, F1:H4. const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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 を返します。

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

戻る

Selection - 現在の選択。

承認

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

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

getSheetById(id)

指定された ID のシートを取得します。Sheet.getSheetId() を使用します。

const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetById(12345);

パラメータ

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

戻る

Sheet - 指定された ID のシート。シートが見つからない場合は null


getSheetByName(name)

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

同じ名前のシートが複数ある場合は、最も左側のシートが返されます。指定された名前のシートがない場合は、null を返します。

// The code below logs the index of a sheet named "Expenses" const 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) などのメソッドと組み合わせて使用すると便利です。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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()

シート名を返します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

指定された座標から始まるこの範囲の値の長方形のグリッドを返します。行または列の位置として -1 の値が指定された場合、シート内のデータを含む最後の行または列を取得することと同じになります。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // The two samples below produce the same output let values = sheet.getSheetValues(1, 1, 3, 3); Logger.log(values);  const 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 const sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets(); // Iterates through the sheets and logs the name and ID of each sheet. for (const sheet of sheets) {   Logger.log(`name: ${sheet.getName()}, ID: ${sheet.getSheetId()}`); }

戻る

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. const 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 - タイムゾーン。Joda.org に記載されているように、「long」形式で指定します(例: 「America/New_York」)。

承認

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

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

getUrl()

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

const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // This hides the first column let range = sheet.getRange('A1'); sheet.hideColumn(range);  // This hides the first 3 columns 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // This hides the first row const range = sheet.getRange('A1'); sheet.hideRow(range);

パラメータ

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

承認

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

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

insertColumnAfter(afterPosition)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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 です。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  const binaryData = [];  // TODO(developer): Replace with your binary data. const 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 の最大サイズは 2 MB です。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  const binaryData = [];  // TODO(developer): Replace with your binary data. const 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 は一般公開されている必要があります。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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 は一般公開されている必要があります。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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()

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

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

戻る

Sheet - 新しいシート。

承認

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

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

insertSheet(sheetIndex)

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

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

パラメータ

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

戻る

Sheet - 新しいシート。

承認

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

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

insertSheet(sheetIndex, options)

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

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

パラメータ

名前説明
sheetIndexInteger新しく作成されたシートのインデックス。シートをスプレッドシートの最初のシートとして挿入するには、0 に設定します。
optionsObject省略可能な JavaScript の高度な引数。

拡張パラメータ

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

戻る

Sheet - 新しいシート。

承認

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

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

insertSheet(options)

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

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

パラメータ

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

拡張パラメータ

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

戻る

Sheet - 新しいシート。

承認

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

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

insertSheet(sheetName)

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

const 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)

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

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

パラメータ

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

戻る

Sheet - 新しいシート。

承認

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

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

insertSheet(sheetName, sheetIndex, options)

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

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

パラメータ

名前説明
sheetNameString新しいシートの名前。
sheetIndexInteger新しく挿入されたシートのインデックス。シートをスプレッドシートの最初のシートとして挿入するには、0 に設定します。
optionsObject省略可能な JavaScript の高度な引数。

拡張パラメータ

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

戻る

Sheet - 新しいシート。

承認

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

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

insertSheet(sheetName, options)

指定された名前で新しいシートをスプレッドシートに挿入し、必要に応じて高度な引数を使用します。新しいシートがアクティブなシートになります。

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

パラメータ

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

拡張パラメータ

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

戻る

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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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. const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // Gets the "first" sheet and activates it. const 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 ベースのインデックス位置。

承認

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

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

moveChartToObjectSheet(chart)

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

const sheet = SpreadsheetApp.getActiveSheet(); const chart = sheet.newChart().setPosition(1, 1, 0, 0).build(); sheet.insertChart(chart); const 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() {   const ss = SpreadsheetApp.getActiveSpreadsheet();   ss.addMenu('badMenu', [     {name: 'remove bad menu', functionName: 'removeBadMenu'},     {name: 'foo', functionName: 'foo'},   ]); } function removeBadMenu() {   const 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. const 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)

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

const 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 になります。

const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const range = sheet.getRange('A1:D4'); sheet.setActiveRange(range);  const selection = sheet.getSelection(); // Current cell: A1 const currentCell = selection.getCurrentCell(); // Active Range: A1:D4 const 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 として設定されます。

const sheet = SpreadsheetApp.getActiveSheet(); const rangeList = sheet.getRangeList(['D4', 'B2:C4']); sheet.setActiveRangeList(rangeList);  const selection = sheet.getSelection(); // Current cell: B2 const currentCell = selection.getCurrentCell(); // Active range: B2:C4 const activeRange = selection.getActiveRange(); // Active range list: [D4, B2:C4] const activeRangeList = selection.getActiveRangeList();

パラメータ

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

戻る

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

承認

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

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

setActiveSelection(range)

このシートのアクティブな選択範囲を設定します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  const 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 表記で指定されたアクティブな選択範囲を設定します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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. const 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 に表示されます。

const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const firstSheet = spreadsheet.getSheets()[0]; const 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 const range = spreadsheet.getActiveSheet().getSelection().getActiveRange(); Logger.log(range.getA1Notation());

パラメータ

名前説明
sheetSheet新しいアクティブ シート。
restoreSelectionBooleantrue の場合、新しいシートがアクティブになると、新しいアクティブ シートの最新の選択が再び選択されます。false の場合、現在の選択を変更せずに新しいシートがアクティブになります。

戻る

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

承認

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

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

setColumnWidth(columnPosition, width)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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 つのセルで構成されている必要があります。そうでない場合は例外がスローされます。

const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const cell = sheet.getRange('B5'); sheet.setCurrentCell(cell);  const selection = sheet.getSelection(); // Current cell: B5 const currentCell = selection.getCurrentCell();

パラメータ

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

戻る

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

承認

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

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

setFrozenColumns(columns)

指定された数の列を固定します。0 の場合、列は固定されません。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

指定された数の行を固定します。0 の場合、行は固定されません。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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反復計算を有効にする場合は true、それ以外の場合は false

戻る

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 const 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) を使用します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); // The code below sets the second predefined theme as the current theme of the // spreadsheet. const 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」形式で指定。例: Joda.org に記載されている「America/New_York」)。

承認

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

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

show(userInterface)

ユーザーのブラウザのビューポートの中央に表示されるダイアログに、カスタム ユーザー インターフェース コンポーネントを表示します。サーバーサイド スクリプトの実行は一時停止されません。サーバーサイドと通信するには、ユーザー インターフェース コンポーネントがサーバーサイド スクリプトに非同期コールバックを行う必要があります。

サーバーサイド スクリプトが以前に表示したダイアログがまだ閉じられていない場合、既存のダイアログは、新たにリクエストされたダイアログのユーザー インターフェースに置き換えられます。

次のコード スニペットは、指定されたタイトル、高さ、幅のダイアログに単純な HtmlService アプリケーションを表示します。

const 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)

シートを列で昇順に並べ替えます。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

シートを列で並べ替えます。昇順または降順を指定するパラメータを受け取ります。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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)

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

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // This unhides the first column if it was previously hidden const range = sheet.getRange('A1'); sheet.unhideColumn(range);

パラメータ

名前説明
columnRange非表示にする範囲(非表示の場合)。

承認

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

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

unhideRow(row)

指定された範囲の行を再表示します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const sheet = ss.getSheets()[0];  // This unhides the first row if it was previously hidden const 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) とまったく同じように動作します。

const ss = SpreadsheetApp.getActiveSpreadsheet(); const 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

サポート終了のメソッド