Class Table

جدول

يشير ذلك المصطلح إلى عنصر يمثّل جدولاً. يمكن أن يتضمّن 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()

لإنشاء TableRow جديد وإلحاقه به.

استرجاع الكرة

TableRow - عنصر صف الجدول الجديد

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

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);

المَعلمات

الاسمTypeالوصف
tableRowTableRowصف الجدول المطلوب إرفاقه

استرجاع الكرة

TableRow — عنصر صف الجدول الملحق

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

clear()

لمحو محتوى العنصر.

استرجاع الكرة

Table - العنصر الحالي


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)

للبحث في محتوى العنصر عن عنصر تابع من النوع المحدد.

المَعلمات

الاسمTypeالوصف
elementTypeElementTypeنوع العنصر للبحث عنه

استرجاع الكرة

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;
  }
}

المَعلمات

الاسمTypeالوصف
elementTypeElementTypeنوع العنصر للبحث عنه
fromRangeElementنتيجة البحث للبحث منها

استرجاع الكرة

RangeElement - نتيجة بحث تشير إلى الموضع التالي لعنصر البحث

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

findText(searchPattern)

للبحث في محتويات العنصر عن نمط النص المحدد باستخدام التعبيرات العادية.

هناك مجموعة فرعية من ميزات التعبير العادي في JavaScript غير متوافقة بالكامل، مثل مجموعات الالتقاط ومعدِّلات الأوضاع.

تتم مطابقة نمط التعبير العادي المقدّم بشكل مستقل مع كل كتلة نصية مضمَّنة في العنصر الحالي.

المَعلمات

الاسمTypeالوصف
searchPatternStringالنمط للبحث عن

استرجاع الكرة

RangeElement: نتيجة بحث تشير إلى موضع نص البحث، وتكون قيمة فارغة في حال عدم التطابق

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

findText(searchPattern, from)

للبحث في محتوى العنصر عن نمط النص المحدد، بدءًا من نتيجة بحث معينة.

هناك مجموعة فرعية من ميزات التعبير العادي في JavaScript غير متوافقة بالكامل، مثل مجموعات الالتقاط ومعدِّلات الأوضاع.

تتم مطابقة نمط التعبير العادي المقدّم بشكل مستقل مع كل كتلة نصية مضمَّنة في العنصر الحالي.

المَعلمات

الاسمTypeالوصف
searchPatternStringالنمط للبحث عن
fromRangeElementنتيجة البحث للبحث منها

استرجاع الكرة

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());

المَعلمات

الاسمTypeالوصف
rowIndexIntegerفهرس الصف الذي يحتوي على الخلية المطلوب استردادها.
cellIndexIntegerفهرس الخلية المطلوب استرداده.

استرجاع الكرة

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.");
}

المَعلمات

الاسمTypeالوصف
childIndexIntegerفهرس العنصر الفرعي لاسترداد

استرجاع الكرة

Element - العنصر الفرعي في الفهرس المحدد

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getChildIndex(child)

لاسترداد الفهرس الفرعي للعنصر الفرعي المحدد

المَعلمات

الاسمTypeالوصف
childElementالعنصر الفرعي المطلوب استرداد الفهرس له

استرجاع الكرة

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));

المَعلمات

الاسمTypeالوصف
columnIndexIntegerفهرس العمود.

استرجاع الكرة

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());

المَعلمات

الاسمTypeالوصف
rowIndexIntegerفهرس الصف المطلوب استرداده.

استرجاع الكرة

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 جديد وإدراجه في الفهرس المحدّد.

المَعلمات

الاسمTypeالوصف
childIndexIntegerالفهرس الذي يتم إدراج العنصر فيه

استرجاع الكرة

TableRow - العنصر الحالي

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertTableRow(childIndex, tableRow)

لإدراج TableRow المحدّد في الفهرس المحدّد.

المَعلمات

الاسمTypeالوصف
childIndexIntegerالفهرس الذي يتم إدراج العنصر فيه
tableRowTableRowصف الجدول لإدراج

استرجاع الكرة

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());

المَعلمات

الاسمTypeالوصف
childElementالعنصر الفرعي المطلوب إزالته.

استرجاع الكرة

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);

المَعلمات

الاسمTypeالوصف
rowIndexIntegerفهرس الصف المطلوب إزالته.

استرجاع الكرة

TableRow — الصف الذي تمت إزالته.

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

replaceText(searchPattern, replacement)

لاستبدال جميع تكرارات نمط نص معين بسلسلة استبدال معينة، باستخدام تعبيرات عادية.

يتم تمرير نمط البحث كسلسلة، وليس ككائن تعبير عادي JavaScript. لهذا السبب، ستحتاج إلى تجنب أي شرطات مائلة للخلف في النمط.

تستخدم هذه الطريقة مكتبة التعبيرات العادية RE2 من Google، ما يحدّ من البنية المتوافقة.

تتم مطابقة نمط التعبير العادي المقدّم بشكل مستقل مع كل كتلة نصية مضمَّنة في العنصر الحالي.

var body = DocumentApp.getActiveDocument().getBody();

// Clear the text surrounding "Apps Script", with or without text.
body.replaceText("^.*Apps ?Script.*$", "Apps Script");

المَعلمات

الاسمTypeالوصف
searchPatternStringنمط التعبير العادي للبحث عن
replacementStringالنص المطلوب استخدامه كبديل

استرجاع الكرة

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);

المَعلمات

الاسمTypeالوصف
attributesObjectتمثّل هذه السمة سمات العنصر.

استرجاع الكرة

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');

المَعلمات

الاسمTypeالوصف
colorStringلون الحدود، منسَّقًا في ترميز CSS (مثل '#ffffff').

استرجاع الكرة

Table - العنصر الحالي

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setBorderWidth(width)

لضبط عرض الحدود بالنقاط

المَعلمات

الاسمTypeالوصف
widthNumberعرض الحدود بالنقاط

استرجاع الكرة

Table - العنصر الحالي

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setColumnWidth(columnIndex, width)

لضبط عرض العمود المحدد بالنقاط.

المَعلمات

الاسمTypeالوصف
columnIndexIntegerفهرس العمود
widthNumberعرض الحدود بالنقاط

استرجاع الكرة

Table - العنصر الحالي

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setLinkUrl(url)

تُحدِّد عنوان URL للرابط.

المَعلمات

الاسمTypeالوصف
urlStringعنوان 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);

المَعلمات

الاسمTypeالوصف
textAlignmentTextAlignmentنوع محاذاة النص المراد تطبيقه

استرجاع الكرة

Table - العنصر الحالي

التفويض

تتطلب النصوص البرمجية التي تستخدم هذه الطريقة الحصول على تفويض باستخدام واحد أو أكثر من النطاقات التالية:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents