عنصر يمثّل جدولاً لا يمكن أن يحتوي Table إلا على عناصر TableRow. لمزيد من المعلومات حول بنية المستند، يُرجى الاطّلاع على دليل توسيع نطاق "مستندات 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 | تضبط هذه السمة محاذاة النص. |
مستندات تفصيلية
appendTableRow()
appendTableRow(tableRow)
تُلحق هذه الطريقة TableRow المحدّدة.
// 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 | صف الجدول الذي سيتم إلحاقه. |
الإرجاع
TableRow: عنصر صف الجدول الذي تم إلحاقه
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
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
editAsText()
يحصل على نسخة Text من العنصر الحالي لتعديلها.
استخدِم editAsText لمعالجة محتوى العناصر كنص منسّق. يتجاهل الوضع editAsText العناصر غير النصية (مثل InlineImage وHorizontalRule).
تتم إزالة العناصر الفرعية التي يتم تضمينها بالكامل في نطاق نصي محذوف من العنصر.
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: نسخة نصية من العنصر الحالي
findElement(elementType)
يبحث في محتوى العنصر عن عنصر فرعي من النوع المحدّد.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
element | Element | نوع العنصر المطلوب البحث عنه. |
الإرجاع
RangeElement|null: نتيجة بحث تشير إلى موضع عنصر البحث.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findElement(elementType, from)
يبحث في محتويات العنصر عن عنصر فرعي من النوع المحدّد، بدءًا من RangeElement المحدّد.
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 | نتيجة البحث التي سيتم البحث منها |
الإرجاع
RangeElement|null: نتيجة بحث تشير إلى الموضع التالي لعنصر البحث.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findText(searchPattern)
يبحث في محتوى العنصر عن نمط النص المحدّد باستخدام التعبيرات العادية.
لا تتوافق مجموعة فرعية من ميزات التعبير العادي في JavaScript بشكل كامل، مثل مجموعات الالتقاط ومعدّلات الوضع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | النمط المطلوب البحث عنه |
الإرجاع
RangeElement|null — نتيجة بحث تشير إلى موضع نص البحث، أو قيمة فارغة إذا لم تكن هناك أي مطابقة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
يبحث في محتوى العنصر عن نمط النص المحدّد، بدءًا من نتيجة بحث معيّنة.
لا تتوافق مجموعة فرعية من ميزات التعبير العادي في JavaScript بشكل كامل، مثل مجموعات الالتقاط ومعدّلات الوضع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل كتلة نصية مضمّنة في العنصر الحالي.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
search | String | النمط المطلوب البحث عنه |
from | Range | نتيجة البحث التي تريد البحث منها |
الإرجاع
RangeElement|null: نتيجة بحث تشير إلى الموضع التالي لنص البحث، أو قيمة فارغة إذا لم تكن هناك أي مطابقة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getAttributes()
يتم استرداد سمات العنصر.
والنتيجة هي عنصر يحتوي على سمة لكل سمة عنصر صالحة، حيث يتطابق اسم كل سمة مع عنصر في التعداد DocumentApp.Attribute.
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
getBorderColor()
تعرض هذه السمة لون الحدود.
// 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
getBorderWidth()
تعرض هذه السمة عرض الحدود بالنقاط.
// 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
getCell(rowIndex, cellIndex)
تسترد هذه الدالة TableCell في فهرسَي الصف والخلية المحدّدين.
// 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 | فهرس الخلية المطلوب استردادها. |
الإرجاع
TableCell|null: خلية الجدول
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getChild(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
getChildIndex(child)
يستردّ هذا الإجراء فهرس العنصر الفرعي للعنصر الفرعي المحدّد.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Element | العنصر الفرعي الذي سيتم استرداد الفهرس الخاص به. |
الإرجاع
Integer: فهرس الطفل
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getColumnWidth(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
getLinkUrl()
تعرض هذه السمة عنوان URL للرابط.
الإرجاع
String|null: عنوان URL للرابط، أو null إذا كان العنصر يحتوي على قيم متعددة لهذه السمة
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNextSibling()
يستردّ العنصر الشقيق التالي للعنصر.
العنصر الشقيق التالي له العنصر الرئيسي نفسه ويتبع العنصر الحالي.
الإرجاع
Element|null: العنصر الشقيق التالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNumChildren()
تعرض هذه السمة عدد الأطفال.
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
getNumRows()
تعرض عدد TableRows.
// 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
getParent()
تعرض هذه السمة العنصر الرئيسي للعنصر الحالي.
يحتوي العنصر الرئيسي على العنصر الحالي.
الإرجاع
ContainerElement|null: العنصر الرئيسي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPreviousSibling()
يتم استرداد العنصر الشقيق السابق للعنصر.
العنصر الشقيق السابق له العنصر الأصلي نفسه ويسبق العنصر الحالي.
الإرجاع
Element|null: العنصر الشقيق السابق
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getRow(rowIndex)
تعرض TableRow في فهرس الصف المحدّد.
// 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 | فهرس الصف المطلوب استرداده. |
الإرجاع
TableRow|null: صف الجدول
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getText()
تعرض محتوى العنصر كسلسلة نصية.
الإرجاع
String: محتوى العنصر كسلسلة نصية
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getTextAlignment()
تعرض هذه السمة محاذاة النص. تشمل أنواع المحاذاة المتاحة DocumentApp.TextAlignment.NORMAL وDocumentApp.TextAlignment.SUBSCRIPT وDocumentApp.TextAlignment.SUPERSCRIPT.
الإرجاع
TextAlignment|null: نوع محاذاة النص، أو null إذا كان النص يحتوي على أنواع متعدّدة من محاذاة النص أو إذا لم يتم ضبط محاذاة النص مطلقًا
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getType()
يستردّ ElementType الخاص بالعنصر.
استخدِم getType() لتحديد النوع الدقيق لعنصر معيّن.
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.'); }
الإرجاع
ElementType: نوع العنصر
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertTableRow(childIndex)
تنشئ هذه الطريقة TableRow جديدًا وتُدرجه في الفهرس المحدّد.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Integer | الفهرس الذي سيتم إدراج العنصر فيه |
الإرجاع
TableRow: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertTableRow(childIndex, tableRow)
تُدرِج هذه الدالة TableRow المحدّدة في الفهرس المحدّد.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
child | Integer | الفهرس الذي سيتم إدراج العنصر فيه |
table | Table | صف الجدول المطلوب إدراجه |
الإرجاع
TableRow: عنصر صف الجدول الذي تم إدراجه
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
isAtDocumentEnd()
تحدّد هذه السمة ما إذا كان العنصر في نهاية Document.
الإرجاع
Boolean: ما إذا كان العنصر في نهاية علامة التبويب.
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
removeChild(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
removeFromParent()
تزيل هذه الطريقة العنصر من العنصر الأصل.
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
removeRow(rowIndex)
تزيل هذه الدالة TableRow في فهرس الصف المحدّد.
// 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 | فهرس الصف المطلوب إزالته. |
الإرجاع
TableRow: الصف الذي تمت إزالته
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
replaceText(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
setAttributes(attributes)
تضبط هذه السمة سمات العنصر.
يجب أن تكون مَعلمة السمات المحدّدة عبارة عن عنصر يكون فيه كل اسم خاصية عنصرًا في التعداد DocumentApp.Attribute، وتكون كل قيمة خاصية هي القيمة الجديدة التي سيتم تطبيقها.
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
setBorderColor(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
setBorderWidth(width)
تضبط هذه السمة عرض الحدود بالنقاط.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
width | Number | عرض الحدود بالنقاط |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setColumnWidth(columnIndex, width)
تضبط هذه السمة عرض العمود المحدّد بالنقاط.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
column | Integer | فهرس العمود |
width | Number | عرض الحدود بالنقاط |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setLinkUrl(url)
يضبط عنوان URL للرابط.
المَعلمات
| الاسم | النوع | الوصف |
|---|---|---|
url | String | عنوان URL للرابط |
الإرجاع
Table: العنصر الحالي
التفويض
تتطلّب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على إذن باستخدام نطاق واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setTextAlignment(textAlignment)
تضبط هذه السمة محاذاة النص. تشمل أنواع المحاذاة المتاحة DocumentApp.TextAlignment.NORMAL وDocumentApp.TextAlignment.SUBSCRIPT وDocumentApp.TextAlignment.SUPERSCRIPT.
// 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