عنصر يمثل جدولاً. لا يمكن أن يحتوي Table
إلا على عناصر TableRow
. لمزيد من المعلومات حول بنية المستند، يمكنك الاطلاع على دليل توسيع "مستندات Google".
عند إنشاء Table
يحتوي على عدد كبير من الصفوف أو الخلايا، ننصحك بإنشائه من مصفوفة سلسلة، كما هو موضّح في المثال التالي.
var body = DocumentApp.getActiveDocument().getBody(); // Create a two-dimensional array containing the cell contents. var 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);
الطُرق
الطريقة | نوع الإرجاع | وصف قصير |
---|---|---|
appendTableRow() | TableRow | تنشئ السمة TableRow الجديدة وتُلحِقها. |
appendTableRow(tableRow) | TableRow | تُرفِق TableRow المحدّدة. |
clear() | Table | يمحو محتوى العنصر. |
copy() | Table | عرض نسخة عميقة ومنفصلة للعنصر الحالي. |
editAsText() | Text | للحصول على نسخة Text من العنصر الحالي لتعديلها. |
findElement(elementType) | RangeElement | يبحث في محتوى العنصر الخاص بعنصر تابع من النوع المحدّد. |
findElement(elementType, from) | RangeElement | يبحث في محتوى العنصر عن عنصر تابع من النوع المحدّد، بدءًا من RangeElement المحدّد. |
findText(searchPattern) | RangeElement | يبحث في محتوى العنصر لنمط النص المحدد باستخدام التعبيرات العادية. |
findText(searchPattern, from) | RangeElement | يبحث في محتوى العنصر عن النمط النصي المحدّد، بدءًا من نتيجة بحث معيّنة. |
getAttributes() | Object | لاسترداد سمات العنصر. |
getBorderColor() | String | استرجاع لون الحدود. |
getBorderWidth() | Number | لاسترداد عرض الحدود، بالنقاط. |
getCell(rowIndex, cellIndex) | TableCell | استرداد TableCell في الصف وفهارس الخلايا المحدّدين |
getChild(childIndex) | Element | استرداد العنصر الثانوي في الفهرس الفرعي المحدد. |
getChildIndex(child) | Integer | استرداد الفهرس الفرعي للعنصر الفرعي المحدّد |
getColumnWidth(columnIndex) | Number | لاسترداد عرض عمود الجدول المحدَّد، بالنقاط. |
getLinkUrl() | String | استرداد عنوان URL للرابط. |
getNextSibling() | Element | لاسترداد العنصر التالي التابع للعنصر. |
getNumChildren() | Integer | استرجاع عدد الأطفال |
getNumRows() | Integer | استرداد عدد TableRows |
getParent() | ContainerElement | لاسترداد العنصر الرئيسي للعنصر. |
getPreviousSibling() | Element | لاسترداد العنصر شقيق سابق للعنصر. |
getRow(rowIndex) | TableRow | استرداد TableRow في فهرس الصف المحدد |
getText() | String | استرجاع محتوى العنصر كسلسلة نصية. |
getTextAlignment() | TextAlignment | للحصول على محاذاة النص. |
getType() | ElementType | لاسترداد ElementType للعنصر. |
insertTableRow(childIndex) | TableRow | تنشئ السمة TableRow الجديدة وتدرجها في الفهرس المحدّد. |
insertTableRow(childIndex, tableRow) | TableRow | إدخال TableRow المحددة في الفهرس المحدد. |
isAtDocumentEnd() | Boolean | تُحدِّد هذه السياسة ما إذا كان العنصر في نهاية Document . |
removeChild(child) | Table | إزالة العنصر الفرعي المحدّد |
removeFromParent() | Table | إزالة العنصر من العنصر الرئيسي |
removeRow(rowIndex) | TableRow | تزيل TableRow في فهرس الصف المحدد. |
replaceText(searchPattern, replacement) | Element | يستبدل جميع تكرارات نمط نص معين بسلسلة بديلة معينة باستخدام التعبيرات العادية. |
setAttributes(attributes) | Table | تحدد سمات العنصر. |
setBorderColor(color) | Table | لضبط لون الحدود |
setBorderWidth(width) | Table | لضبط عرض الحدود بالنقاط. |
setColumnWidth(columnIndex, width) | Table | لضبط عرض العمود المحدّد، بالنقاط. |
setLinkUrl(url) | Table | لضبط عنوان URL للرابط. |
setTextAlignment(textAlignment) | 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('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first table in the document 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);
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
tableRow | TableRow | صف الجدول المطلوب إلحاقه. |
رحلة العودة
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
).
بالنسبة إلى العناصر الثانوية المضمَّنة بالكامل في نطاق نص محذوف، تتم إزالتها من العنصر.
var body = DocumentApp.getActiveDocument().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)
يبحث في محتوى العنصر الخاص بعنصر تابع من النوع المحدّد.
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
elementType | ElementType | نوع العنصر المطلوب البحث عنه |
رحلة العودة
RangeElement
: نتيجة بحث تشير إلى موضع عنصر البحث
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findElement(elementType, from)
يبحث في محتوى العنصر عن عنصر تابع من النوع المحدّد، بدءًا من RangeElement
المحدّد.
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Define the search parameters. var searchType = DocumentApp.ElementType.PARAGRAPH; var searchHeading = DocumentApp.ParagraphHeading.HEADING1; var searchResult = null; // Search until the paragraph is found. while (searchResult = body.findElement(searchType, searchResult)) { var par = searchResult.getElement().asParagraph(); if (par.getHeading() == searchHeading) { // Found one, update and stop. par.setText('This is the first header.'); return; } }
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
elementType | ElementType | نوع العنصر المطلوب البحث عنه |
from | RangeElement | نتيجة البحث لإجراء بحث من |
رحلة العودة
RangeElement
: نتيجة بحث تشير إلى الموضع التالي لعنصر البحث
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern)
يبحث في محتوى العنصر لنمط النص المحدد باستخدام التعبيرات العادية.
هناك مجموعة فرعية من ميزات التعبير العادي في JavaScript غير متوافقة بالكامل، مثل مجموعات الالتقاط ومفاتيح تعديل الأوضاع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل مربّع نص مضمّن في العنصر الحالي.
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
searchPattern | String | النمط المطلوب البحث عنه |
رحلة العودة
RangeElement
: نتيجة بحث تشير إلى موضع نص البحث أو قيمة فارغة في حال عدم توفّر مطابقة
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
يبحث في محتوى العنصر عن النمط النصي المحدّد، بدءًا من نتيجة بحث معيّنة.
هناك مجموعة فرعية من ميزات التعبير العادي في JavaScript غير متوافقة بالكامل، مثل مجموعات الالتقاط ومفاتيح تعديل الأوضاع.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل مربّع نص مضمّن في العنصر الحالي.
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
searchPattern | String | النمط المطلوب البحث عنه |
from | RangeElement | نتيجة البحث لإجراء بحث من |
رحلة العودة
RangeElement
: نتيجة بحث تشير إلى الموضع التالي لنص البحث أو قيمة فارغة في حال عدم توفّر مطابقة
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAttributes()
لاسترداد سمات العنصر.
والنتيجة هي عنصر يحتوي على سمة لكل سمة عنصر صالحة حيث يتطابق كل اسم سمة مع عنصر في تعداد DocumentApp.Attribute
.
var body = DocumentApp.getActiveDocument().getBody(); // Append a styled paragraph. var par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. var atts = par.getAttributes(); // Log the paragraph attributes. for (var 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('abc123456'); // Gets the document body. const body = doc.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
: لون الحدّ منسَّق في تدوين 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('abc123456'); // Gets the document body. const body = doc.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
: عرض الحدود بالنقاط.
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
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('abc123456'); // Gets the document body. const body = doc.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());
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
rowIndex | Integer | فهرس الصف الذي يحتوي على الخلية المطلوب استردادها. |
cellIndex | Integer | فهرس الخلية المراد استردادها |
رحلة العودة
TableCell
- خلية الجدول
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getChild(childIndex)
استرداد العنصر الثانوي في الفهرس الفرعي المحدد.
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document. var 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."); }
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
childIndex | 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('abc123456'); // Gets the document body. const body = doc.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));
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
columnIndex | Integer | فهرس العمود |
رحلة العودة
Number
: عرض العمود بالنقاط.
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLinkUrl()
استرداد عنوان URL للرابط.
رحلة العودة
String
: عنوان URL للرابط أو قيمة فارغة إذا كان العنصر يحتوي على قيم متعدّدة لهذه السمة
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNextSibling()
لاسترداد العنصر التالي التابع للعنصر.
العنصر الرئيسي التالي له العنصر الرئيسي نفسه ويتّبع العنصر الحالي.
رحلة العودة
Element
: العنصر المقابل التالي
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNumChildren()
استرجاع عدد الأطفال
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Log the number of elements in the document. Logger.log("There are " + body.getNumChildren() + " elements in the document 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('abc123456'); // Gets the document body. const body = doc.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
: العنصر الرئيسي
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPreviousSibling()
لاسترداد العنصر شقيق سابق للعنصر.
العنصر الرئيسي السابق له العنصر الرئيسي نفسه ويسبق العنصر الحالي.
رحلة العودة
Element
: العنصر السابق التابع
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
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('abc123456'); // Gets the document body. const body = doc.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());
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
rowIndex | Integer | فهرس الصف المطلوب استرداده. |
رحلة العودة
TableRow
- صف الجدول.
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
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
إذا كان النص يحتوي على أنواع متعددة من محاذاة النص أو إذا لم يتم ضبط محاذاة النص مطلقًا
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getType()
لاسترداد ElementType
للعنصر.
يمكنك استخدام getType()
لتحديد النوع الدقيق لعنصر معيّن.
var body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document body. var 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
الجديدة وتدرجها في الفهرس المحدّد.
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
childIndex | Integer | الفهرس الذي يجب إدراج العنصر فيه |
رحلة العودة
TableRow
— العنصر الحالي
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertTableRow(childIndex, tableRow)
إدخال TableRow
المحددة في الفهرس المحدد.
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
childIndex | Integer | الفهرس الذي يجب إدراج العنصر فيه |
tableRow | TableRow | صف الجدول المطلوب إدراجه |
رحلة العودة
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('abc123456'); // Gets the document body. const body = doc.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()
إزالة العنصر من العنصر الرئيسي
var body = DocumentApp.getActiveDocument().getBody(); // Remove all images in the document body. var imgs = body.getImages(); for (var i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
رحلة العودة
Table
— العنصر الذي تمت إزالته
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
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('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first table and removes its second row. const table = body.getTables()[0]; table.removeRow(1);
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
rowIndex | Integer | فهرس الصف المطلوب إزالته. |
رحلة العودة
TableRow
: الصف الذي تمت إزالته
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
replaceText(searchPattern, replacement)
يستبدل جميع تكرارات نمط نص معين بسلسلة بديلة معينة باستخدام التعبيرات العادية.
يتم تمرير نمط البحث كسلسلة، وليس كعنصر تعبير عادي في JavaScript. لهذا السبب، عليك تجنُّب أي شرطة مائلة للخلف في النمط.
وتستخدِم هذه الطرق مكتبة التعبير العادي RE2 التي تفرض قيودًا على البنية المتوافقة.
تتم مطابقة نمط التعبير العادي المقدَّم بشكل مستقل مع كل مربّع نص مضمّن في العنصر الحالي.
var body = DocumentApp.getActiveDocument().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText("^.*Apps ?Script.*$", "Apps Script");
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
searchPattern | String | نمط regex للبحث عن |
replacement | String | النص المطلوب استخدامه كبديل |
رحلة العودة
Element
— العنصر الحالي
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAttributes(attributes)
تحدد سمات العنصر.
يجب أن تكون معلّمة السمات المحدّدة عنصرًا حيث يكون كل اسم خاصية عنصرًا في التعداد DocumentApp.Attribute
وتكون كل قيمة للسمة هي القيمة الجديدة التي سيتم تطبيقها.
var body = DocumentApp.getActiveDocument().getBody(); // Define a custom paragraph style. var 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. var 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('abc123456'); // Gets the document body. const body = doc.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)
لضبط عرض العمود المحدّد، بالنقاط.
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
columnIndex | 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 be superscript. var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
المَعلمات
الاسم | النوع | الوصف |
---|---|---|
textAlignment | TextAlignment | نوع محاذاة النص الذي سيتم تطبيقه |
رحلة العودة
Table
— العنصر الحالي
التفويض
إنّ النصوص البرمجية التي تستخدم هذه الطريقة تتطلب تفويضًا باستخدام واحد أو أكثر من النطاقات التالية:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents