访问和修改现有数据源公式。要创建新的数据源公式,请使用 Range.setFormula(formula)
。
该类仅适用于连接到数据库的数据。
方法
方法 | 返回类型 | 简介 |
---|---|---|
forceRefreshData() | DataSourceFormula | 刷新此对象的数据,而不考虑当前状态。 |
getAnchorCell() | Range | 返回表示此数据源公式锚定的单元格的 Range 。 |
getDataSource() | DataSource | 获取对象关联的数据源。 |
getDisplayValue() | String | 返回数据源公式的显示值。 |
getFormula() | String | 返回此数据源公式的公式。 |
getStatus() | DataExecutionStatus | 获取对象的数据执行状态。 |
refreshData() | DataSourceFormula | 刷新对象的数据。 |
setFormula(formula) | DataSourceFormula | 更新公式。 |
waitForCompletion(timeoutInSeconds) | DataExecutionStatus | 等待当前执行完成,在提供的秒数后超时。 |
详细文档
forceRefreshData()
刷新此对象的数据,而不考虑当前状态。如需了解详情,请参阅 refreshData()
。
如果数据源类型未启用,则会抛出异常。使用 SpreadsheetApp#enable...Execution()
方法可针对特定数据源类型启用数据执行。
弃踢回攻
DataSourceFormula
- 数据对象。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getAnchorCell()
getDataSource()
获取对象关联的数据源。
弃踢回攻
DataSource
- 数据源。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getDisplayValue()
返回数据源公式的显示值。
弃踢回攻
String
- 显示值。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getFormula()
返回此数据源公式的公式。
弃踢回攻
String
- 公式。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
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()
方法可针对特定数据源类型启用数据执行。
弃踢回攻
DataSourceFormula
- 数据对象。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setFormula(formula)
更新公式。
参数
名称 | 类型 | 说明 |
---|---|---|
formula | String | 新公式。 |
弃踢回攻
DataSourceFormula
- 数据源公式,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
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