تمثّل هذه السمة عنصرًا يمثّل جدولاً. لا يمكن أن يحتوي Table إلا على عناصر Table. لمزيد من المعلومات حول بنية المستند، يُرجى الاطّلاع على دليل توسيع نطاق "مستندات Google".
عند إنشاء Table يحتوي على عدد كبير من الصفوف أو الخلايا، ننصحك بإنشائه من مصفوفة سلاسل، كما هو موضّح في المثال التالي.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Create a two-dimensional array containing the cell contents. const cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'], ]; // Build a table from the array. body.appendTable(cells);
الطُرق
| الطريقة | نوع القيمة التي يتم إرجاعها | وصف قصير |
|---|---|---|
append | Table | تنشئ هذه السمة Table جديدة وتلحقها. |
append | Table | تُلحق هذه السمة Table المحدّدة. |
clear() | Table | يمحو محتوى العنصر. |
copy() | Table | تعرض نسخة منفصلة وعميقة من العنصر الحالي. |
edit | Text | يحصل على نسخة Text من العنصر الحالي لتعديلها. |
find | Range | يبحث في محتوى العنصر عن عنصر فرعي من النوع المحدّد. |
find | Range | يبحث في محتويات العنصر عن عنصر فرعي من النوع المحدّد، بدءًا من Range المحدّد. |
find | Range | يبحث في محتوى العنصر عن نمط النص المحدّد باستخدام التعبيرات العادية. |
find | Range | يبحث في محتوى العنصر عن نمط النص المحدّد، بدءًا من نتيجة بحث معيّنة. |
get | Object | يستردّ سمات العنصر. |
get | String|null | تعرض هذه السمة لون الحدود. |
get | Number|null | تعرض هذه السمة عرض الحدود بالنقاط. |
get | Table | تسترد هذه الدالة Table في فهرسَي الصف والخلية المحدّدين. |
get | Element | يستردّ العنصر الفرعي في فهرس العنصر الفرعي المحدّد. |
get | Integer | يستردّ هذا الإجراء فهرس العنصر الفرعي للعنصر الفرعي المحدّد. |
get | Number|null | تعرض هذه الدالة عرض عمود الجدول المحدّد بالنقاط. |
get | String|null | تعرض هذه السمة عنوان URL للرابط. |
get | Element|null | يستردّ العنصر الشقيق التالي للعنصر. |
get | Integer | تعرض هذه السمة عدد الأطفال. |
get | Integer | تعرض عدد Table. |
get | Container | تعرض هذه السمة العنصر الرئيسي للعنصر الحالي. |
get | Element|null | يستردّ هذا الإجراء العنصر الشقيق السابق للعنصر. |
get | Table | تعرض Table في فهرس الصف المحدّد. |
get | String | تعرض محتوى العنصر كسلسلة نصية. |
get | Text | تعرض هذه السمة محاذاة النص. |
get | Element | يستردّ Element العنصر. |
insert | Table | تُنشئ هذه الطريقة عنصر Table جديدًا وتُدرجه في الفهرس المحدّد. |
insert | Table | تُدرِج هذه الدالة القيمة Table المحدّدة في الفهرس المحدّد. |
is | Boolean | تحدّد هذه السمة ما إذا كان العنصر في نهاية Document. |
remove | Table | يزيل العنصر الفرعي المحدّد. |
remove | Table|null | يزيل العنصر من العنصر الأصل. |
remove | Table | تزيل هذه الدالة Table في فهرس الصف المحدّد. |
replace | Element | لاستبدال جميع تكرارات نمط نصي معيّن بسلسلة استبدال معيّنة، باستخدام التعبيرات العادية. |
set | Table | تضبط هذه السمة سمات العنصر. |
set | Table | تضبط هذه السمة لون الحدود. |
set | Table | تضبط هذه السمة عرض الحدود بالنقاط. |
set | Table | تضبط هذه السمة عرض العمود المحدّد بالنقاط. |
set | Table | يضبط عنوان URL للرابط. |
set | Table | تضبط هذه السمة محاذاة النص. |
مستندات تفصيلية
append Table Row()
append Table Row(tableRow)
تُلحق هذه السمة Table المحدّدة.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table in the tab and copies the second row. const table = body.getTables()[0]; const row = table.getChild(1).copy(); // Adds the copied row to the bottom of the table. const tableRow = table.appendTableRow(row);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
table | Table | صف الجدول الذي سيتم إلحاقه. |
الإرجاع
Table: عنصر صف الجدول الملحق
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
clear()
copy()
تعرض نسخة منفصلة وعميقة من العنصر الحالي.
يتم أيضًا نسخ أي عناصر فرعية مضمّنة في العنصر. لا يحتوي العنصر الجديد على عنصر رئيسي.
الإرجاع
Table: النسخة الجديدة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
edit As Text()
يحصل على نسخة Text من العنصر الحالي لتعديلها.
استخدِم edit لمعالجة محتوى العناصر كنص منسّق. يتجاهل الوضع edit العناصر غير النصية (مثل Inline وHorizontal).
تتم إزالة العناصر الفرعية التي يتم تضمينها بالكامل في نطاق نص محذوف من العنصر.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Insert two paragraphs separated by a paragraph containing an // horizontal rule. body.insertParagraph(0, 'An editAsText sample.'); body.insertHorizontalRule(0); body.insertParagraph(0, 'An example.'); // Delete " sample.\n\n An" removing the horizontal rule in the process. body.editAsText().deleteText(14, 25);
الإرجاع
Text: نسخة نصية من العنصر الحالي
find Element(elementType)
يبحث في محتوى العنصر عن عنصر فرعي من النوع المحدّد.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
element | Element | نوع العنصر المطلوب البحث عنه. |
الإرجاع
Range: نتيجة بحث تشير إلى موضع عنصر البحث.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Element(elementType, from)
يبحث في محتويات العنصر عن عنصر فرعي من النوع المحدّد، بدءًا من Range المحدّد.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Define the search parameters. let searchResult = null; // Search until the paragraph is found. while ( (searchResult = body.findElement( DocumentApp.ElementType.PARAGRAPH, searchResult, ))) { const par = searchResult.getElement().asParagraph(); if (par.getHeading() === DocumentApp.ParagraphHeading.HEADING1) { // Found one, update and stop. par.setText('This is the first header.'); break; } }
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
element | Element | نوع العنصر المطلوب البحث عنه. |
from | Range | نتيجة البحث التي سيتم البحث منها |
الإرجاع
Range: نتيجة بحث تشير إلى الموضع التالي لعنصر البحث.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern)
يبحث في محتوى العنصر عن نمط النص المحدّد باستخدام التعبيرات العادية.
لا تتوافق مجموعة فرعية من ميزات التعبيرات العادية في JavaScript بشكل كامل، مثل مجموعات الالتقاط ومعدّلات الوضع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | النمط المطلوب البحث عنه |
الإرجاع
Range — نتيجة بحث تشير إلى موضع نص البحث، أو قيمة فارغة إذا لم تكن هناك أي مطابقة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern, from)
يبحث في محتوى العنصر عن نمط النص المحدّد، بدءًا من نتيجة بحث معيّنة.
لا تتوافق مجموعة فرعية من ميزات التعبيرات العادية في JavaScript بشكل كامل، مثل مجموعات الالتقاط ومعدّلات الوضع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | النمط المطلوب البحث عنه |
from | Range | نتيجة البحث التي تريد البحث منها |
الإرجاع
Range: نتيجة بحث تشير إلى الموضع التالي لنص البحث، أو قيمة فارغة إذا لم تكن هناك أي مطابقة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes()
يستردّ سمات العنصر.
والنتيجة هي عنصر يحتوي على سمة لكل سمة عنصر صالحة، حيث يتطابق اسم كل سمة مع عنصر في التعداد Document.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Append a styled paragraph. const par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. const atts = par.getAttributes(); // Log the paragraph attributes. for (const att in atts) { Logger.log(`${att}:${atts[att]}`); }
الإرجاع
Object: سمات العنصر
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Border Color()
تعرض هذه السمة لون الحدود.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table. const table = body.getTables()[0]; // Sets the border color of the first table. table.setBorderColor('#00FF00'); // Logs the border color of the first table to the console. console.log(table.getBorderColor());
الإرجاع
String|null: لون الحد، بتنسيق CSS (مثل '#ffffff').
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Border Width()
تعرض هذه السمة عرض الحدود بالنقاط.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table. const table = body.getTables()[0]; // Sets the border width of the first table. table.setBorderWidth(20); // Logs the border width of the first table. console.log(table.getBorderWidth());
الإرجاع
Number|null: تمثّل هذه السمة عرض الحدود بالنقاط.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Cell(rowIndex, cellIndex)
تسترد هذه الدالة Table في فهرسَي الصف والخلية المحدّدين.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table. const table = body.getTables()[0]; // Gets the cell of the table's third row and second column. const cell = table.getCell(2, 1); // Logs the cell text to the console. console.log(cell.getText());
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
row | Integer | فهرس الصف الذي يحتوي على الخلية المطلوب استردادها |
cell | Integer | فهرس الخلية المطلوب استردادها. |
الإرجاع
Table: خلية الجدول
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Child(childIndex)
يستردّ العنصر الفرعي في فهرس العنصر الفرعي المحدّد.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Obtain the first element in the tab. const firstChild = body.getChild(0); // If it's a paragraph, set its contents. if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) { firstChild.asParagraph().setText('This is the first paragraph.'); }
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Integer | فهرس العنصر الفرعي المطلوب استرداده |
الإرجاع
Element: العنصر الفرعي في الفهرس المحدّد
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Child Index(child)
يستردّ هذا الإجراء فهرس العنصر الفرعي للعنصر الفرعي المحدّد.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Element | العنصر الثانوي الذي سيتم استرداد الفهرس الخاص به. |
الإرجاع
Integer: فهرس الطفل
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Column Width(columnIndex)
تعرض هذه الدالة عرض عمود الجدول المحدّد بالنقاط.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table. const table = body.getTables()[0]; // Sets the width of the second column to 100 points. const columnWidth = table.setColumnWidth(1, 100); // Gets the width of the second column and logs it to the console. console.log(columnWidth.getColumnWidth(1));
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
column | Integer | فهرس العمود |
الإرجاع
Number|null: تمثّل عرض العمود بالنقاط.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url()
تعرض هذه السمة عنوان URL للرابط.
الإرجاع
String|null: عنوان URL للرابط، أو null إذا كان العنصر يحتوي على قيم متعددة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Next Sibling()
يستردّ العنصر الشقيق التالي للعنصر.
العنصر الشقيق التالي له العنصر الرئيسي نفسه ويتبع العنصر الحالي.
الإرجاع
Element|null: العنصر الشقيق التالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Num Children()
تعرض هذه السمة عدد الأطفال.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Log the number of elements in the tab. Logger.log(`There are ${body.getNumChildren()} elements in the tab's body.`);
الإرجاع
Integer: عدد الأطفال
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Num Rows()
تعرض عدد Table.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table. const table = body.getTables()[0]; // Logs the number of rows of the first table to the console. console.log(table.getNumRows());
الإرجاع
Integer: عدد صفوف الجدول
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Parent()
تعرض هذه السمة العنصر الرئيسي للعنصر الحالي.
يحتوي العنصر الرئيسي على العنصر الحالي.
الإرجاع
Container: العنصر الرئيسي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Previous Sibling()
يستردّ هذا الإجراء العنصر الشقيق السابق للعنصر.
العنصر الشقيق السابق له العنصر الرئيسي نفسه ويسبق العنصر الحالي.
الإرجاع
Element|null: العنصر الشقيق السابق
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Row(rowIndex)
تعرض Table في فهرس الصف المحدّد.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table and logs the text of first row to the console. const table = body.getTables()[0]; console.log(table.getRow(0).getText());
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
row | Integer | فهرس الصف المطلوب استرداده. |
الإرجاع
Table: صف الجدول
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text()
تعرض محتوى العنصر كسلسلة نصية.
الإرجاع
String: محتوى العنصر كسلسلة نصية
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment()
تعرض هذه السمة محاذاة النص. تشمل أنواع المحاذاة المتاحة Document وDocument وDocument.
الإرجاع
Text: نوع محاذاة النص، أو null إذا كان النص يحتوي على أنواع متعدّدة من محاذاة النص أو إذا لم يتم ضبط محاذاة النص مطلقًا
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Type()
يستردّ Element العنصر.
استخدِم get لتحديد النوع الدقيق لعنصر معيّن.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Obtain the first element in the active tab's body. const firstChild = body.getChild(0); // Use getType() to determine the element's type. if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) { Logger.log('The first element is a paragraph.'); } else { Logger.log('The first element is not a paragraph.'); }
الإرجاع
Element: نوع العنصر
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Table Row(childIndex)
تُنشئ هذه الطريقة عنصر Table جديدًا وتُدرجه في الفهرس المحدّد.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Integer | الفهرس الذي سيتم إدراج العنصر فيه |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Table Row(childIndex, tableRow)
تُدرِج هذه الدالة القيمة Table المحدّدة في الفهرس المحدّد.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Integer | الفهرس الذي سيتم إدراج العنصر فيه |
table | Table | صف الجدول المطلوب إدراجه |
الإرجاع
Table: عنصر صف الجدول الذي تم إدراجه
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is At Document End()
تحدّد هذه السمة ما إذا كان العنصر في نهاية Document.
الإرجاع
Boolean: ما إذا كان العنصر في نهاية علامة التبويب.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Child(child)
يزيل العنصر الفرعي المحدّد.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table. const table = body.getTables()[0]; // Finds the first table row and removes it. const element = table.findElement(DocumentApp.ElementType.TABLE_ROW); table.removeChild(element.getElement());
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Element | عنصر الطفل الذي ستتم إزالته. |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove From Parent()
يزيل العنصر من العنصر الأصل.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Remove all images in the active tab's body. const imgs = body.getImages(); for (let i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
الإرجاع
Table|null: العنصر الذي تمت إزالته
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Row(rowIndex)
تزيل هذه الدالة Table في فهرس الصف المحدّد.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table and removes its second row. const table = body.getTables()[0]; table.removeRow(1);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
row | Integer | فهرس الصف المطلوب إزالته. |
الإرجاع
Table: الصف الذي تمت إزالته
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
replace Text(searchPattern, replacement)
لاستبدال جميع تكرارات نمط نصي معيّن بسلسلة استبدال معيّنة، باستخدام التعبيرات العادية.
يتم تمرير نمط البحث كسلسلة، وليس ككائن تعبير عادي في JavaScript. لهذا السبب، عليك تخطّي أي شرطات مائلة عكسية في النمط.
تستخدِم هذه الطريقة مكتبة RE2 للتعبيرات العادية من Google، ما يحدّ من البنية المتوافقة.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText('^.*Apps ?Script.*$', 'Apps Script');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | نمط التعبير العادي الذي سيتم البحث عنه |
replacement | String | النص الذي سيتم استخدامه كبديل |
الإرجاع
Element: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Attributes(attributes)
تضبط هذه السمة سمات العنصر.
يجب أن تكون مَعلمة السمات المحدّدة عبارة عن عنصر يكون فيه كل اسم خاصية عنصرًا في التعداد Document، وكل قيمة خاصية هي القيمة الجديدة التي سيتم تطبيقها.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Define a custom paragraph style. const style = {}; style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT; style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri'; style[DocumentApp.Attribute.FONT_SIZE] = 18; style[DocumentApp.Attribute.BOLD] = true; // Append a plain paragraph. const par = body.appendParagraph('A paragraph with custom style.'); // Apply the custom style. par.setAttributes(style);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
attributes | Object | سمات العنصر |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Border Color(color)
تضبط هذه السمة لون الحدود.
// Opens the Docs file by its ID. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Gets the first table. const table = body.getTables()[0]; // Sets the border color of the table to green. table.setBorderColor('#00FF00');
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
color | String | لون الحدود، بتنسيق CSS (مثل '#ffffff') |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Border Width(width)
تضبط هذه السمة عرض الحدود بالنقاط.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
width | Number | عرض الحدود بالنقاط |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Column Width(columnIndex, width)
تضبط هذه السمة عرض العمود المحدّد بالنقاط.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
column | Integer | فهرس العمود |
width | Number | عرض الحدود بالنقاط |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Link Url(url)
يضبط عنوان URL للرابط.
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
url | String | عنوان URL للرابط |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text Alignment(textAlignment)
تضبط هذه السمة محاذاة النص. تشمل أنواع المحاذاة المتاحة Document وDocument وDocument.
// Make the entire first paragraph in the active tab be superscript. const documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab(); const text = documentTab.getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
المعلمات
| الاسم | النوع | الوصف |
|---|---|---|
text | Text | نوع محاذاة النص المطلوب تطبيقه |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents