Class DataSourceColumn
Stay organized with collections
Save and categorize content based on your preferences.
DataSourceColumn
Access and modify a data source column.
Only use this class with data that's connected to a database.
Detailed documentation
getDataSource()
Gets the data source associated with the data source column.
Return
DataSource
— 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
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
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
DataSourceColumn
— 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
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[null,null,["Last updated 2024-12-02 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eDataSourceColumn\u003c/code\u003e class allows you to programmatically access and modify data source columns connected to a database in Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eYou can get and set the formula and name for calculated columns, as well as get the associated data source and check for array dependencies.\u003c/p\u003e\n"],["\u003cp\u003eThis class provides methods for checking if a column is calculated or has array dependencies, along with the ability to remove calculated columns.\u003c/p\u003e\n"],["\u003cp\u003eAll methods within the \u003ccode\u003eDataSourceColumn\u003c/code\u003e class require authorization with specific Google Sheets scopes.\u003c/p\u003e\n"]]],[],null,["# Class DataSourceColumn\n\nDataSourceColumn\n\nAccess and modify a data source column.\n\n\n**Only use this class with data that's connected to a database.** \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------|--------------------------------------------------------------|--------------------------------------------------------------|\n| [getDataSource()](#getDataSource()) | [DataSource](/apps-script/reference/spreadsheet/data-source) | Gets the data source associated with the data source column. |\n| [getFormula()](#getFormula()) | `String` | Gets the formula for the data source column. |\n| [getName()](#getName()) | `String` | Gets the name for the data source column. |\n| [hasArrayDependency()](#hasArrayDependency()) | `Boolean` | Returns whether the column has an array dependency. |\n| [isCalculatedColumn()](#isCalculatedColumn()) | `Boolean` | Returns whether the column is a calculated column. |\n| [remove()](#remove()) | `void` | Removes the data source column. |\n| [setFormula(formula)](#setFormula(String)) | [DataSourceColumn](#) | Sets the formula for the data source column. |\n| [setName(name)](#setName(String)) | [DataSourceColumn](#) | Sets the name of the data source column. |\n\nDetailed documentation\n----------------------\n\n### `get``Data``Source()`\n\nGets the data source associated with the data source column.\n\n#### Return\n\n\n[DataSource](/apps-script/reference/spreadsheet/data-source) --- The data source.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Formula()`\n\nGets the formula for the data source column. Returns an empty string if the data source column\nis not a [calculated column](#isCalculatedColumn()).\n\n#### Return\n\n\n`String` --- The formula.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `get``Name()`\n\nGets the name for the data source column.\n\n#### Return\n\n\n`String` --- The column name.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `has``Array``Dependency()`\n\nReturns whether the column has an array dependency.\n\n#### Return\n\n\n`Boolean` --- `true` if the column has an array dependency, or `false` otherwise.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `is``Calculated``Column()`\n\nReturns whether the column is a calculated column.\n\n#### Return\n\n\n`Boolean` --- `true` if the column is a calculated column, or `false` otherwise.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `remove()`\n\nRemoves the data source column.\n\nOnly supported for [calculated columns](#isCalculatedColumn()).\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Formula(formula)`\n\nSets the formula for the data source column.\n\nOnly supported for [calculated columns](#isCalculatedColumn()).\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------|----------|------------------|\n| `formula` | `String` | The new formula. |\n\n#### Return\n\n\n[DataSourceColumn](#) --- The data source column, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`\n\n*** ** * ** ***\n\n### `set``Name(name)`\n\nSets the name of the data source column.\n\nOnly supported for [calculated columns](#isCalculatedColumn()).\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|----------|------------------|\n| `name` | `String` | The name to set. |\n\n#### Return\n\n\n[DataSourceColumn](#) --- The data source column, for chaining.\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/spreadsheets.currentonly`\n- `https://www.googleapis.com/auth/spreadsheets`"]]