存取及修改現有的資料來源工作表。如要建立新的資料來源工作表,請使用 Spreadsheet.insertDataSourceSheet(spec)
。
請僅將這個類別用於連結至資料庫的資料。
方法
內容詳盡的說明文件
addFilter(columnName, filterCriteria)
新增已套用至資料來源工作表的篩選器。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 要套用此篩選器的資料欄名稱。 |
filterCriteria | FilterCriteria | 要套用的篩選條件。 |
回攻員
DataSourceSheet
— 用於方法鏈的資料來源工作表。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
asSheet()
autoResizeColumn(columnName)
自動調整指定資料欄的寬度。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 資料欄名稱。 |
回攻員
DataSourceSheet
— 此資料來源工作表,用於鏈結。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
autoResizeColumns(columnNames)
自動調整指定欄的寬度。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnNames | String[] | 要更新的資料欄名稱清單。 |
回攻員
DataSourceSheet
— 此資料來源工作表,用於鏈結。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
forceRefreshData()
重新整理這個物件的資料,無論目前狀態為何。詳情請參閱 refreshData()
。
如果資料來源類型未啟用,就會擲回例外狀況。使用 SpreadsheetApp#enable...Execution()
方法,即可針對特定資料來源類型啟用資料執行功能。
回攻員
DataSourceSheet
:資料物件。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getColumnWidth(columnName)
傳回指定資料欄的寬度。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 資料欄名稱。 |
回攻員
Integer
:資料欄的寬度;如果資料欄使用預設寬度,則為 null
。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDataSource()
取得物件連結的資料來源。
回攻員
DataSource
:資料來源。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getFilters()
傳回已套用至資料來源工作表的所有篩選器。
回攻員
DataSourceSheetFilter[]
:套用至資料來源工作表的所有篩選器陣列。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSheetValues(columnName)
傳回指定資料欄名稱的資料來源工作表的所有值。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 要擷取其值的資料來源資料欄名稱。 |
回攻員
Object[]
:一維值陣列。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
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[]
:一維值陣列。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getSortSpecs()
取得資料來源工作表中的所有排序規格。
回攻員
SortSpec[]
:排序規格的清單。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getStatus()
取得物件的資料執行狀態。
回攻員
DataExecutionStatus
:資料執行狀態。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
refreshData()
重新整理物件資料。
如果目前處於 error
狀態,就會擲回例外狀況。請使用 DataSource#updateSpec()
來更新規格。此方法建議優先於 forceRefreshData()
,以免資料來源發生非預期的編輯作業。
如果資料來源類型未啟用,就會擲回例外狀況。使用 SpreadsheetApp#enable...Execution()
方法,即可針對特定資料來源類型啟用資料執行功能。
回攻員
DataSourceSheet
:資料物件。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
removeFilters(columnName)
移除已套用至資料來源工作表欄的所有篩選器。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 要從中移除篩選器的資料欄名稱。 |
回攻員
DataSourceSheet
— 用於方法鏈的資料來源工作表。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
removeSortSpec(columnName)
移除資料來源工作表中資料欄的排序規格。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 資料欄的名稱。 |
回攻員
DataSourceSheet
— 用於鏈結的資料來源工作表。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setColumnWidth(columnName, width)
設定指定資料欄的寬度。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 資料欄名稱。 |
width | Integer | 資料欄的新寬度。 |
回攻員
DataSourceSheet
— 此資料來源工作表,用於鏈結。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setColumnWidths(columnNames, width)
設定指定資料欄的寬度。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnNames | String[] | 要更新的資料欄名稱清單。 |
width | Integer | 資料欄的新寬度。 |
回攻員
DataSourceSheet
— 此資料來源工作表,用於鏈結。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setSortSpec(columnName, ascending)
為資料來源工作表中的資料欄設定排序規格。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 要排序的資料欄名稱。 |
ascending | Boolean | 如果值為 true ,請遞增排序資料欄;如果是 false ,則會以遞減順序排序資料欄。 |
回攻員
DataSourceSheet
— 用於鏈結的資料來源工作表。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setSortSpec(columnName, sortOrder)
為資料來源工作表中的資料欄設定排序規格。
參數
名稱 | 類型 | 說明 |
---|---|---|
columnName | String | 要排序的資料欄名稱。 |
sortOrder | SortOrder | 排列順序。 |
回攻員
DataSourceSheet
— 用於鏈結的資料來源工作表。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
waitForCompletion(timeoutInSeconds)
等到目前的執行作業完成,在指定的秒數過後逾時。如果執行作業在逾時後未完成,但不會取消資料執行,就會擲回例外狀況。
參數
名稱 | 類型 | 說明 |
---|---|---|
timeoutInSeconds | Integer | 等待資料執行的時間 (以秒為單位)。長度上限為 300 秒。 |
回攻員
DataExecutionStatus
:資料執行狀態。
授權
使用這個方法的指令碼必須取得以下一或多個範圍的授權:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets