Stay organized with collections Save and categorize content based on your preferences.
DataSourceAccess and modify existing data source. To create a data source table with new data source, see DataSourceTable
.
Only use this class with data that's connected to a database.
Detailed documentationcancelAllLinkedDataSourceObjectRefreshes()
Cancels all currently running refreshes of data source objects linked to this data source.
This example shows how to cancel all the refreshes of a data source.
SpreadsheetApp.enableBigQueryExecution(); const spreadsheet = SpreadsheetApp.getActiveSpreadsheet(); const dataSource = spreadsheet.getDataSources()[0]; dataSource.cancelAllLinkedDataSourceObjectRefreshes();
Throws an exception if the data source type is not enabled. Use SpreadsheetApp#enable...Execution()
methods to enable data execution for the specific data source type.
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
createCalculatedColumn(name, formula)
Creates a calculated column. This method is only available for BigQuery data sources.
Parameters Name Type Descriptionname
String
The name of the calculated column. formula
String
The calculated column formula. Return
DataSourceColumn
— The newly created calculated column.
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
createDataSourcePivotTableOnNewSheet()
Creates a data source pivot table from this data source in the first cell of a new sheet. As a side effect, makes the new sheet the active sheet.
ReturnDataSourcePivotTable
— The newly created data source pivot table.
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
createDataSourceTableOnNewSheet()
Creates a data source table from this data source in the first cell of a new sheet. As a side effect, makes the new sheet the active sheet.
This method is only available for BigQuery data sources.
ReturnDataSourceTable
— The newly created data source table.
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
getCalculatedColumnByName(columnName)
Returns the calculated column in the data source that matches the column name.
Parameters Name Type DescriptioncolumnName
String
The name of the calculated column to get. Return
DataSourceColumn
— The calculated column that matches the column name, or null
if there is no such calculated column.
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
getCalculatedColumns()
Returns all the calculated columns in the data source.
Data source specs of DataSourceType.LOOKER
type returns an empty array.
DataSourceColumn[]
— An array of all the calculated columns in the data source.
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
getColumns()
Returns all the columns in the data source.
ReturnDataSourceColumn[]
— An array of all the DataSourceColumn
in the data source.
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
getDataSourceSheets()
Returns the data source sheets associated with this data source.
ReturnDataSourceSheet[]
— An array of data source sheets.
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
getSpec()
Gets the data source specification.
ReturnDataSourceSpec
— The data source specification.
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
refreshAllLinkedDataSourceObjects()
Refreshes all data source objects linked to the data source.
Throws an exception if the data source type is not enabled. Use SpreadsheetApp#enable...Execution()
methods to enable data execution for the specific data source type.
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
updateSpec(spec)
Updates the data source specification and refreshes the data source objects linked with this data source with the new specification.
Throws an exception if the data source type is not enabled. Use SpreadsheetApp#enable...Execution()
methods to enable data execution for the specific data source type.
Throws an exception if the data source specification type is of a different type than the current data source type.
Parameters Name Type Descriptionspec
DataSourceSpec
The data source specification to update with. Return
DataSource
— The data source.
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
updateSpec(spec, refreshAllLinkedObjects)
Updates the data source specification and refreshes the linked data source sheets
with the new specification.
Throws an exception if the data source type is not enabled. Use SpreadsheetApp#enable...Execution()
methods to enable data execution for the specific data source type.
Throws an exception if the data source specification type is of a different type than the current data source type.
Parameters Name Type Descriptionspec
DataSourceSpec
The data source specification to update with. refreshAllLinkedObjects
Boolean
If true
, also refreshes all the data source objects linked with this data source. Return
DataSource
— The data source.
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
waitForAllDataExecutionsCompletion(timeoutInSeconds)
Waits until all the current executions of the linked data source objects complete, timing out after the provided number of seconds. Throws an exception if the executions are not completed when timing out, but does not cancel the data executions.
Parameters Name Type DescriptiontimeoutInSeconds
Integer
The time to wait for data executions, in seconds. The maximum is 300 seconds. 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-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[[["The `DataSource` class is used to access and modify existing data sources connected to a database within Google Sheets."],["It provides methods to manage calculated columns, create pivot tables and data source tables, refresh data, and retrieve data source specifications."],["This class is specifically designed for data connected to databases and should not be used with other types of data."],["Before using `DataSource` methods, you might need to enable data execution for the specific data source type using `SpreadsheetApp#enable...Execution()` methods."],["Using `DataSource` requires authorization with specific scopes like `https://www.googleapis.com/auth/spreadsheets.currentonly` or `https://www.googleapis.com/auth/spreadsheets`."]]],["This `DataSource` class manages data connected to a database. Key actions include creating calculated columns with formulas, and generating new data source pivot tables or tables on new sheets. It allows fetching calculated columns and all columns, retrieving associated data source sheets, and accessing the data source specification. Additionally, it enables refreshing all linked data source objects, updating the specification with or without refresh, canceling refreshes, and waiting for all data executions to complete.\n"]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4