Class LookerDataSourceSpec
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
مواصفاتمصدرالبياناتفي Looker
DataSourceSpec
التي تُستخدَم للوصول إلى مواصفات مصدر بيانات Looker
الحالية على وجه التحديد لإنشاء مواصفات مصدر بيانات جديدة، استخدِم SpreadsheetApp.newDataSourceSpec()
.
يوضّح هذا المثال كيفية الحصول على مواصفات مصدر بيانات Looker من ورقة بيانات تتضمّن اتصالاً واحدًا فقط
بLooker.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
مستندات تفصيلية
copy()
تُنشئ DataSourceSpecBuilder
استنادًا إلى إعدادات مصدر البيانات هذا.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const spec = ss.getDataSources()[0].getSpec();
const newSpec = spec.copy();
الإرجاع
DataSourceSpecBuilder
: المطوّر
getExploreName()
تحصل على اسم استكشاف Looker في النموذج.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
const exploreName = lookerDataSourceSpec.getExploreName();
Logger.log(exploreName);
الإرجاع
String
: اسم استكشاف Looker
getInstanceUrl()
تحصل على عنوان URL لنسخة Looker.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
const instanceUrl = lookerDataSourceSpec.getInstanceUrl();
Logger.log(instanceUrl);
الإرجاع
String
: عنوان URL لنسخة Looker.
getModelName()
تحصل على اسم نموذج Looker في المثيل.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();
const modelName = lookerDataSourceSpec.getModelName();
Logger.log(modelName);
الإرجاع
String
: اسم نموذج Looker
getParameters()
تحصل على مَعلمات مصدر البيانات.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const spec = ss.getDataSources()[0].getSpec();
const parameters = spec.getParameters();
لا تتوفّر هذه الطريقة إلا لمصادر بيانات BigQuery.
الإرجاع
DataSourceParameter[]
- قائمة المَعلمات
getType()
تحصل على نوع مصدر البيانات.
// TODO(developer): Replace the URL with your own.
const ss = SpreadsheetApp.openByUrl(
'https://docs.google.com/spreadsheets/d/abc123456/edit',
);
const spec = ss.getDataSources()[0].getSpec();
const type = spec.getType();
الإرجاع
DataSourceType
: نوع مصدر البيانات
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-26 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003e\u003ccode\u003eLookerDataSourceSpec\u003c/code\u003e enables access to existing Looker data source specifications within Google Sheets.\u003c/p\u003e\n"],["\u003cp\u003eTo create new data source specifications, use \u003ccode\u003eSpreadsheetApp.newDataSourceSpec()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve details such as explore name, instance URL, and model name from a \u003ccode\u003eLookerDataSourceSpec\u003c/code\u003e object.\u003c/p\u003e\n"],["\u003cp\u003eSeveral methods, including \u003ccode\u003ecopy()\u003c/code\u003e, \u003ccode\u003egetExploreName()\u003c/code\u003e, \u003ccode\u003egetInstanceUrl()\u003c/code\u003e, \u003ccode\u003egetModelName()\u003c/code\u003e, \u003ccode\u003egetParameters()\u003c/code\u003e, and \u003ccode\u003egetType()\u003c/code\u003e, are available for interacting with Looker data source specifications.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetParameters()\u003c/code\u003e method is specific to BigQuery data sources and retrieves their parameters.\u003c/p\u003e\n"]]],["The `LookerDataSourceSpec` accesses existing Looker data sources. Key actions include retrieving data source details via methods: `getExploreName()` gets the Looker explore name, `getInstanceUrl()` gets the Looker instance URL, and `getModelName()` gets the Looker model name. `getParameters()` retrieves data source parameters (available only for BigQuery), and `getType()` gets the data source type. The `copy()` method creates a `DataSourceSpecBuilder` based on current settings. You can retrieve the looker data source by using `getDataSources()[0].getSpec().asLooker()`.\n"],null,["# Class LookerDataSourceSpec\n\nLookerDataSourceSpec\n\nA [DataSourceSpec](/apps-script/reference/spreadsheet/data-source-spec) which is used to access specifically the existing Looker data source\nspecifications. To create a new data source specification, use [SpreadsheetApp.newDataSourceSpec()](/apps-script/reference/spreadsheet/spreadsheet-app#newDataSourceSpec()).\n\nThis example shows how you can get the Looker data source spec from a sheet which has just one\nLooker connection.\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);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|\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| [getExploreName()](#getExploreName()) | `String` | Gets the name of the Looker explore in the model. |\n| [getInstanceUrl()](#getInstanceUrl()) | `String` | Gets the URL of the Looker instance. |\n| [getModelName()](#getModelName()) | `String` | Gets the name of the Looker model in the instance. |\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### `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``Explore``Name()`\n\nGets the name of the Looker explore in the model.\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);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst exploreName = lookerDataSourceSpec.getExploreName();\nLogger.log(exploreName);\n```\n\n#### Return\n\n\n`String` --- The name of the Looker explore.\n\n*** ** * ** ***\n\n### `get``Instance``Url()`\n\nGets the URL of the Looker instance.\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);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst instanceUrl = lookerDataSourceSpec.getInstanceUrl();\nLogger.log(instanceUrl);\n```\n\n#### Return\n\n\n`String` --- The URL of the Looker instance.\n\n*** ** * ** ***\n\n### `get``Model``Name()`\n\nGets the name of the Looker model in the instance.\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);\n\nconst lookerDataSourceSpec = ss.getDataSources()[0].getSpec().asLooker();\nconst modelName = lookerDataSourceSpec.getModelName();\nLogger.log(modelName);\n```\n\n#### Return\n\n\n`String` --- The name of the Looker model.\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."]]