AI-generated Key Takeaways
-
The
DataSourceColumn
class allows you to programmatically access and modify data source columns connected to a database in Google Sheets. -
You can get and set the formula and name for calculated columns, as well as get the associated data source and check for array dependencies.
-
This class provides methods for checking if a column is calculated or has array dependencies, along with the ability to remove calculated columns.
-
All methods within the
DataSourceColumn
class require authorization with specific Google Sheets scopes.
Access and modify a data source column.
Only use this class with data that's connected to a database.
Methods
Method | Return type | Brief description |
---|---|---|
get | Data | Gets the data source associated with the data source column. |
get | String | Gets the formula for the data source column. |
get | String | Gets the name for the data source column. |
has | Boolean | Returns whether the column has an array dependency. |
is | Boolean | Returns whether the column is a calculated column. |
remove() | void | Removes the data source column. |
set | Data | Sets the formula for the data source column. |
set | Data | Sets the name of the data source column. |
Detailed documentation
getDataSource()
Gets the data source associated with the data source column.
Return
Data
— The data source.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getFormula()
Gets the formula for the data source column. Returns an empty string if the data source column
is not a calculated column
.
Return
String
— The formula.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
getName()
Gets the name for the data source column.
Return
String
— The column name.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
hasArrayDependency()
Returns whether the column has an array dependency.
Return
Boolean
— true
if the column has an array dependency, or false
otherwise.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
isCalculatedColumn()
Returns whether the column is a calculated column.
Return
Boolean
— true
if the column is a calculated column, or false
otherwise.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
remove()
Removes the data source column.
Only supported for calculated columns
.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setFormula(formula)
Sets the formula for the data source column.
Only supported for calculated columns
.
Parameters
Name | Type | Description |
---|---|---|
formula | String | The new formula. |
Return
Data
— The data source column, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets
setName(name)
Sets the name of the data source column.
Only supported for calculated columns
.
Parameters
Name | Type | Description |
---|---|---|
name | String | The name to set. |
Return
Data
— The data source column, for chaining.
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/spreadsheets.currentonly
-
https://www.googleapis.com/auth/spreadsheets