既存のデータソース シートにアクセスして変更する。新しいデータソース シートを作成するには、Spreadsheet.insertDataSourceSheet(spec)
を使用します。
このクラスは、データベースに接続されているデータでのみ使用します。
Methods
詳細なドキュメント
addFilter(columnName, filterCriteria)
データソース シートに適用されるフィルタを追加します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | このフィルタを適用する列の名前。 |
filterCriteria | FilterCriteria | 適用するフィルタ条件。 |
リターン
DataSourceSheet
- メソッド チェーン用のデータソース シート。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
asSheet()
autoResizeColumn(columnName)
指定した列の幅を自動的に変更します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 列の名前。 |
リターン
DataSourceSheet
- このデータソース シート(チェーン用)。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
autoResizeColumns(columnNames)
指定した列の幅を自動的に変更します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnNames | String[] | 更新する列名のリスト。 |
リターン
DataSourceSheet
- このデータソース シート(チェーン用)。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
forceRefreshData()
現在の状態に関係なく、このオブジェクトのデータを更新します。詳しくは、refreshData()
をご覧ください。
データソース タイプが有効になっていない場合、例外をスローします。特定のデータソース タイプに対してデータ実行を有効にするには、SpreadsheetApp#enable...Execution()
メソッドを使用します。
リターン
DataSourceSheet
- データ オブジェクト。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getColumnWidth(columnName)
指定された列の幅を返します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 列の名前。 |
リターン
Integer
- 列の幅。列がデフォルトの幅を使用している場合は null
です。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSource()
オブジェクトがリンクされているデータソースを取得します。
リターン
DataSource
- データソース。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getFilters()
データソース シートに適用されているすべてのフィルタを返します。
リターン
DataSourceSheetFilter[]
- データソース シートに適用されるすべてのフィルタの配列。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSheetValues(columnName)
指定した列名に対応するデータソース シートのすべての値を返します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 値を取得するデータソースの列名。 |
リターン
Object[]
- 1 次元の値の配列。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSheetValues(columnName, startRow, numRows)
指定された開始行(1 ベース)から numRows
までの指定された列名に対するデータソース シートのすべての値を返します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 値を取得するデータソースの列名。 |
startRow | Integer | 値の取得を開始する行の位置。 |
numRows | Integer | 取得する行数。 |
リターン
Object[]
- 1 次元の値の配列。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSortSpecs()
データソース シートのすべての並べ替え仕様を取得します。
リターン
SortSpec[]
- 並べ替え仕様のリスト。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getStatus()
オブジェクトのデータ実行ステータスを取得します。
リターン
DataExecutionStatus
- データ実行ステータス。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
refreshData()
オブジェクトのデータを更新します。
現在 error
状態の場合、例外をスローします。DataSource#updateSpec()
を使用して仕様を更新します。データソースの予期しない編集を防ぐため、forceRefreshData()
よりもこのメソッドをおすすめします。
データソース タイプが有効になっていない場合、例外をスローします。特定のデータソース タイプに対してデータ実行を有効にするには、SpreadsheetApp#enable...Execution()
メソッドを使用します。
リターン
DataSourceSheet
- データ オブジェクト。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
removeFilters(columnName)
データソース シートの列に適用されているすべてのフィルタを削除します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | フィルタを削除する列の名前。 |
リターン
DataSourceSheet
- メソッド チェーン用のデータソース シート。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
removeSortSpec(columnName)
データソース シートの列の並べ替えの仕様を削除します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 列の名前。 |
リターン
DataSourceSheet
- チェーン用のデータソース シート。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setColumnWidth(columnName, width)
指定された列の幅を設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 列の名前。 |
width | Integer | 列の新しい幅。 |
リターン
DataSourceSheet
- このデータソース シート(チェーン用)。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setColumnWidths(columnNames, width)
指定された列の幅を設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnNames | String[] | 更新する列名のリスト。 |
width | Integer | 列の新しい幅。 |
リターン
DataSourceSheet
- このデータソース シート(チェーン用)。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setSortSpec(columnName, ascending)
データソース シートの列の並べ替えの仕様を設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 並べ替える列の名前。 |
ascending | Boolean | true の場合、列を昇順で並べ替えます。false の場合、列を降順に並べ替えます。 |
リターン
DataSourceSheet
- チェーン用のデータソース シート。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setSortSpec(columnName, sortOrder)
データソース シートの列の並べ替えの仕様を設定します。
パラメータ
名前 | 型 | 説明 |
---|---|---|
columnName | String | 並べ替える列の名前。 |
sortOrder | SortOrder | 並べ替え順。 |
リターン
DataSourceSheet
- チェーン用のデータソース シート。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
waitForCompletion(timeoutInSeconds)
現在の実行が完了するまで待機し、指定された秒数後にタイムアウトします。 タイムアウト時に実行が完了していない場合に例外をスローしますが、データ実行はキャンセルしません。
パラメータ
名前 | 型 | 説明 |
---|---|---|
timeoutInSeconds | Integer | データ実行の待機時間(秒単位)。最大値は 300 秒です。 |
リターン
DataExecutionStatus
- データ実行ステータス。
承認
この方法を使用するスクリプトには、次の 1 つ以上のスコープによる承認が必要です。
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets