يمكنك الوصول إلى الإعدادات العامة لمواصفات مصدر بيانات حالي. للوصول إلى مواصفات مصدر البيانات لنوع معيّن، استخدِم طريقة as...(). لإنشاء مواصفات مصدر بيانات جديدة، استخدِم Spreadsheet.
لا تستخدِم هذه الفئة إلا مع البيانات المرتبطة بقاعدة بيانات.
يوضّح هذا المثال كيفية الحصول على معلومات من مواصفات مصدر بيانات BigQuery.
const dataSourceTable = SpreadsheetApp.getActive() .getSheetByName('Data Sheet 1') .getDataSourceTables()[0]; const spec = dataSourceTable.getDataSource().getSpec(); if (spec.getType() === SpreadsheetApp.DataSourceType.BIGQUERY) { const bqSpec = spec.asBigQuery(); Logger.log('Project ID: %s\n', bqSpec.getProjectId()); Logger.log('Raw query string: %s\n', bqSpec.getRawQuery()); }
يوضّح هذا المثال كيفية الحصول على معلومات من مواصفات مصدر بيانات Looker. يؤدي استخدام as إلى عرض عنصر Looker.
// 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().asLooker(); if (spec.getType() === SpreadsheetApp.DataSourceType.LOOKER) { const lookerSpec = spec.asLooker(); Logger.log('Looker instance URL: %s\n', lookerSpec.getInstanceUrl()); }
الطُرق
| الطريقة | نوع القيمة التي يتم عرضها | وصف قصير |
|---|---|---|
as | Big | تحصل على مواصفات مصدر بيانات BigQuery. |
as | Looker | تحصل على مواصفات مصدر بيانات Looker. |
copy() | Data | تُنشئ Data استنادًا إلى إعدادات مصدر البيانات هذا. |
get | Data | تحصل على مَعلمات مصدر البيانات. |
get | Data | تحصل على نوع مصدر البيانات. |
مستندات تفصيلية
as Big Query()
تحصل على مواصفات مصدر بيانات BigQuery.
الإرجاع
Big: مواصفات مصدر بيانات BigQuery
as Looker()
تحصل على مواصفات مصدر بيانات Looker.
// 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().asLooker();
الإرجاع
Looker: مواصفات مصدر بيانات Looker
copy()
تُنشئ Data استنادًا إلى إعدادات مصدر البيانات هذا.
// 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();
الإرجاع
Data: صانع المحتوى
get Parameters()
تحصل على مَعلمات مصدر البيانات.
// 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.
الإرجاع
Data - قائمة المَعلمات
get Type()
تحصل على نوع مصدر البيانات.
// 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();
الإرجاع
Data: نوع مصدر البيانات