Mit Sammlungen den Überblick behalten Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Datenquellenspezifikation
Ruft die allgemeinen Einstellungen einer vorhandenen Datenquellenspezifikation auf. Wenn Sie auf die Datenquellenspezifikation für einen bestimmten Typ zugreifen möchten, verwenden Sie die Methode as...(). Verwenden Sie SpreadsheetApp.newDataSourceSpec(), um eine neue Datenquellenspezifikation zu erstellen.
Verwenden Sie diese Klasse nur mit Daten, die mit einer Datenbank verbunden sind.
In diesem Beispiel wird gezeigt, wie Sie Informationen aus einer BigQuery-Datenquellenspezifikation abrufen.
In diesem Beispiel wird gezeigt, wie Sie Informationen aus einer Looker-Datenquellenspezifikation abrufen. Mit asLooker() wird ein LookerDataSourceSpec-Objekt zurückgegeben.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec().asLooker();if(spec.getType()===SpreadsheetApp.DataSourceType.LOOKER){constlookerSpec=spec.asLooker();Logger.log('Looker instance URL: %s\n',lookerSpec.getInstanceUrl());}
Ruft die Spezifikation für die Looker-Datenquelle ab.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec().asLooker();
Erstellt eine DataSourceSpecBuilder basierend auf den Einstellungen dieser Datenquelle.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec();constnewSpec=spec.copy();
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec();constparameters=spec.getParameters();
Diese Methode ist nur für BigQuery-Datenquellen verfügbar.
// TODO(developer): Replace the URL with your own.constss=SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/abc123456/edit',);constspec=ss.getDataSources()[0].getSpec();consttype=spec.getType();
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Benötigte Informationen nicht gefunden","missingTheInformationINeed","thumb-down"],["Zu umständlich/zu viele Schritte","tooComplicatedTooManySteps","thumb-down"],["Nicht mehr aktuell","outOfDate","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Problem mit Beispielen/Code","samplesCodeIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-07-26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eDataSourceSpec\u003c/code\u003e provides access to the general settings of an existing database-connected data source.\u003c/p\u003e\n"],["\u003cp\u003eTo access type-specific settings, utilize the \u003ccode\u003eas...()\u003c/code\u003e methods (e.g., \u003ccode\u003easBigQuery()\u003c/code\u003e, \u003ccode\u003easLooker()\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eYou can create a new data source specification using \u003ccode\u003eSpreadsheetApp.newDataSourceSpec()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ecopy()\u003c/code\u003e method facilitates creating a \u003ccode\u003eDataSourceSpecBuilder\u003c/code\u003e to modify existing settings.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003egetParameters()\u003c/code\u003e and \u003ccode\u003egetType()\u003c/code\u003e allow retrieval of data source parameters and type respectively.\u003c/p\u003e\n"]]],["`DataSourceSpec` accesses settings of existing data sources connected to databases. Use `as...()` to access specific types, like `asBigQuery()` or `asLooker()`. Key actions include: retrieving data source type with `getType()`, fetching parameters via `getParameters()`, and creating a modifiable copy using `copy()`. For example, retrieve BigQuery project ID and raw query string, or get a Looker instance URL. This class can not be used with new data source, use `SpreadsheetApp.newDataSourceSpec()` instead.\n"],null,["# Class DataSourceSpec\n\nDataSourceSpec\n\nAccess the general settings of an existing data source spec. To access data source spec for\ncertain type, use `as...()` method. To create a new data source spec, use [SpreadsheetApp.newDataSourceSpec()](/apps-script/reference/spreadsheet/spreadsheet-app#newDataSourceSpec()).\n\n\n**Only use this class with data that's connected to a database.**\n\n\nThis example shows how to get information from a BigQuery data source spec.\n\n```javascript\nconst dataSourceTable = SpreadsheetApp.getActive()\n .getSheetByName('Data Sheet 1')\n .getDataSourceTables()[0];\nconst spec = dataSourceTable.getDataSource().getSpec();\nif (spec.getType() === SpreadsheetApp.DataSourceType.BIGQUERY) {\n const bqSpec = spec.asBigQuery();\n Logger.log('Project ID: %s\\n', bqSpec.getProjectId());\n Logger.log('Raw query string: %s\\n', bqSpec.getRawQuery());\n}\n```\n\nThis example shows how to get information from a Looker data source spec. Using `as``Looker()` returns a [LookerDataSourceSpec](/apps-script/reference/spreadsheet/looker-data-source-spec) object.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec().asLooker();\n\nif (spec.getType() === SpreadsheetApp.DataSourceType.LOOKER) {\n const lookerSpec = spec.asLooker();\n Logger.log('Looker instance URL: %s\\n', lookerSpec.getInstanceUrl());\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-------------------------------------|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\n| [asBigQuery()](#asBigQuery()) | [BigQueryDataSourceSpec](/apps-script/reference/spreadsheet/big-query-data-source-spec) | Gets the spec for BigQuery data source. |\n| [asLooker()](#asLooker()) | [LookerDataSourceSpec](/apps-script/reference/spreadsheet/looker-data-source-spec) | Gets the spec for Looker data source. |\n| [copy()](#copy()) | [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) | Creates a [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) based on this data source's settings. |\n| [getParameters()](#getParameters()) | [DataSourceParameter[]](/apps-script/reference/spreadsheet/data-source-parameter) | Gets the parameters of the data source. |\n| [getType()](#getType()) | [DataSourceType](/apps-script/reference/spreadsheet/data-source-type) | Gets the type of the data source. |\n\nDetailed documentation\n----------------------\n\n### `as``Big``Query()`\n\nGets the spec for BigQuery data source.\n\n#### Return\n\n\n[BigQueryDataSourceSpec](/apps-script/reference/spreadsheet/big-query-data-source-spec) --- The BigQuery data source spec.\n\n*** ** * ** ***\n\n### `as``Looker()`\n\nGets the spec for Looker data source.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec().asLooker();\n```\n\n#### Return\n\n\n[LookerDataSourceSpec](/apps-script/reference/spreadsheet/looker-data-source-spec) --- The Looker data source spec.\n\n*** ** * ** ***\n\n### `copy()`\n\nCreates a [DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) based on this data source's settings.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\n\nconst newSpec = spec.copy();\n```\n\n#### Return\n\n\n[DataSourceSpecBuilder](/apps-script/reference/spreadsheet/data-source-spec-builder) --- The builder.\n\n*** ** * ** ***\n\n### `get``Parameters()`\n\nGets the parameters of the data source.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\nconst parameters = spec.getParameters();\n```\n\nThis method is only available for BigQuery data sources.\n\n#### Return\n\n\n[DataSourceParameter[]](/apps-script/reference/spreadsheet/data-source-parameter) --- The parameter list.\n\n*** ** * ** ***\n\n### `get``Type()`\n\nGets the type of the data source.\n\n```javascript\n// TODO(developer): Replace the URL with your own.\nconst ss = SpreadsheetApp.openByUrl(\n 'https://docs.google.com/spreadsheets/d/abc123456/edit',\n);\nconst spec = ss.getDataSources()[0].getSpec();\nconst type = spec.getType();\n```\n\n#### Return\n\n\n[DataSourceType](/apps-script/reference/spreadsheet/data-source-type) --- The data source type."]]