访问和修改现有数据源工作表。如需创建新的数据源工作表,请使用 Spreadsheet.insertDataSourceSheet(spec)。
仅将此类用于与数据库关联的数据。
方法
详细文档
add
添加应用于数据源工作表的过滤条件。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 要应用此过滤条件的列的名称。 | 
| filter | Filter | 要应用的过滤条件。 | 
返回
Data - 数据源工作表,用于方法链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
as
auto
自动调整指定列的宽度。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 列名称。 | 
返回
Data - 此数据源工作表,用于串联。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
auto
自动调整指定列的宽度。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String[] | 要更新的列名称的列表。 | 
返回
Data - 此数据源工作表,用于串联。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
cancel
取消与此对象关联的数据刷新(如果当前正在运行)。
以下示例展示了如何取消公式刷新。
const spreadsheet = SpreadsheetApp.getActive(); const formula = spreadsheet.getDataSourceFormulas()[0]; // Cancel the ongoing refresh on the formula. formula.cancelDataRefresh();
如果数据源类型未启用,则会抛出异常。使用 Spreadsheet 方法为特定数据源类型启用数据执行。
返回
Data - 数据对象。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
force
无论当前状态如何,都会刷新此对象的数据。如需了解详情,请参阅 refresh。如果您想取消当前正在运行的此对象刷新,请参阅 cancel。
如果数据源类型未启用,则会抛出异常。使用 Spreadsheet 方法为特定数据源类型启用数据执行。
返回
Data - 数据对象。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回指定列的宽度。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 列名称。 | 
返回
Integer - 列的宽度,如果列使用默认宽度,则为 null。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
获取对象关联的数据源。
返回
Data - 数据源。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回应用于数据源工作表的所有过滤条件。
返回
Data - 应用于数据源工作表的所有过滤条件的数组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回指定列名称的数据源工作表的所有值。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 要提取值的数据源列名称。 | 
返回
Object[] - 值的一维数组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
返回指定数据源工作表中指定列名称的所有值,从指定的起始行(从 1 开始)到指定的 num。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 要提取值的数据源列名称。 | 
| start | Integer | 开始提取值的行位置。 | 
| num | Integer | 要提取的行数。 | 
返回
Object[] - 值的一维数组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
获取数据源工作表中的所有排序规范。
返回
Sort - 排序规范列表。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
get
获取对象的数据执行状态。
返回
Data - 数据执行状态。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
refresh
刷新对象的数据。
如果当前处于 error 状态,则会抛出异常。使用 Data 更新规范。建议使用此方法,而不是 force,以防止对数据源进行意外修改。
如果数据源类型未启用,则会抛出异常。使用 Spreadsheet 方法为特定数据源类型启用数据执行。
返回
Data - 数据对象。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
remove
移除应用于数据源工作表列的所有过滤条件。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 要移除过滤条件的列的名称。 | 
返回
Data - 数据源工作表,用于方法链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
remove
移除数据源工作表中列的排序规范。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 列的名称。 | 
返回
Data - 数据源工作表,用于串联。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置指定列的宽度。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 列名称。 | 
| width | Integer | 列的新宽度。 | 
返回
Data - 此数据源工作表,用于串联。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置指定列的宽度。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String[] | 要更新的列名称的列表。 | 
| width | Integer | 列的新宽度。 | 
返回
Data - 此数据源工作表,用于串联。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置数据源工作表中列的排序规范。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 要排序的列的名称。 | 
| ascending | Boolean | 如果为 true,则按升序对此列排序;如果为false,则按降序对此列排序。 | 
返回
Data - 数据源工作表,用于串联。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
set
设置数据源工作表中列的排序规范。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| column | String | 要排序的列的名称。 | 
| sort | Sort | 排序顺序。 | 
返回
Data - 数据源工作表,用于串联。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets
wait
等待当前执行操作完成,并在提供的秒数后超时。 如果超时时执行未完成,则会抛出异常,但不会取消数据执行。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| timeout | Integer | 等待数据执行的时间(以秒为单位)。最长为 300 秒。 | 
返回
Data - 数据执行状态。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/spreadsheets.currentonly
- 
https://www.googleapis.com/auth/spreadsheets