Элемент, представляющий таблицу. Table может содержать только элементы Table Row . Дополнительную информацию о структуре документа см. в руководстве по расширению Google Docs .
 При создании 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 Row() |  Table Row |  Создает и добавляет новую Table Row . | 
 append Table Row(tableRow) |  Table Row |  Добавляет данную Table Row . | 
 clear() |  Table | Очищает содержимое элемента. | 
 copy() |  Table | Возвращает отдельную глубокую копию текущего элемента. | 
 edit As Text() |  Text |  Получает Text версию текущего элемента для редактирования. | 
 find Element(elementType) |  Range Element | Ищет в содержимом элемента потомка указанного типа. | 
 find Element(elementType, from) |  Range Element |  Ищет в содержимом элемента потомка указанного типа, начиная с указанного Range Element . | 
 find Text(searchPattern) |  Range Element | Ищет в содержимом элемента указанный текстовый шаблон с помощью регулярных выражений. | 
 find Text(searchPattern, from) |  Range Element | Ищет в содержимом элемента указанный текстовый шаблон, начиная с заданного результата поиска. | 
 get Attributes() |  Object | Получает атрибуты элемента. | 
 get Border Color() |  String | Получает цвет границы. | 
 get Border Width() |  Number | Получает ширину границы в пунктах. | 
 get Cell(rowIndex, cellIndex) |  Table Cell |  Извлекает Table Cell по указанным индексам строки и ячейки. | 
 get Child(childIndex) |  Element | Извлекает дочерний элемент по указанному дочернему индексу. | 
 get Child Index(child) |  Integer | Получает дочерний индекс для указанного дочернего элемента. | 
 get Column Width(columnIndex) |  Number | Получает ширину указанного столбца таблицы в пунктах. | 
 get Link Url() |  String | Получает URL-адрес ссылки. | 
 get Next Sibling() |  Element | Извлекает следующий родственный элемент элемента. | 
 get Num Children() |  Integer | Получает количество детей. | 
 get Num Rows() |  Integer |  Получает количество Table Rows . | 
 get Parent() |  Container Element | Извлекает родительский элемент элемента. | 
 get Previous Sibling() |  Element | Извлекает предыдущий родственный элемент элемента. | 
 get Row(rowIndex) |  Table Row |  Извлекает Table Row по указанному индексу строки. | 
 get Text() |  String | Извлекает содержимое элемента в виде текстовой строки. | 
 get Text Alignment() |  Text Alignment | Получает выравнивание текста. | 
 get Type() |  Element Type |  Получает Element Type элемента. | 
 insert Table Row(childIndex) |  Table Row |  Создает и вставляет новую Table Row по указанному индексу. | 
 insert Table Row(childIndex, tableRow) |  Table Row |  Вставляет данную Table Row по указанному индексу. | 
 is At Document End() |  Boolean |  Определяет, находится ли элемент в конце Document . | 
 remove Child(child) |  Table | Удаляет указанный дочерний элемент. | 
 remove From Parent() |  Table | Удаляет элемент из его родителя. | 
 remove Row(rowIndex) |  Table Row |  Удаляет Table Row по указанному индексу строки. | 
 replace Text(searchPattern, replacement) |  Element | Заменяет все вхождения данного текстового шаблона заданной строкой замены, используя регулярные выражения. | 
 set Attributes(attributes) |  Table | Устанавливает атрибуты элемента. | 
 set Border Color(color) |  Table | Устанавливает цвет границы. | 
 set Border Width(width) |  Table | Устанавливает ширину границы в пунктах. | 
 set Column Width(columnIndex, width) |  Table | Устанавливает ширину указанного столбца в пунктах. | 
 set Link Url(url) |  Table | Устанавливает URL-адрес ссылки. | 
 set Text Alignment(textAlignment) |  Table | Устанавливает выравнивание текста. | 
Подробная документация
 append Table Row()
 Создает и добавляет новую Table Row .
Возвращаться
 Table Row — новый элемент строки таблицы.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 append Table Row(tableRow)
 Добавляет данную Table Row .
// 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 Row |  Table Row | Строка таблицы, которую требуется добавить. | 
Возвращаться
 Table Row — добавленный элемент строки таблицы.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
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 As Text для управления содержимым элементов в виде форматированного текста. Режим edit As Text игнорирует нетекстовые элементы (такие как Inline Image и Horizontal Rule ).
Дочерние элементы, полностью содержащиеся в удаленном текстовом диапазоне, удаляются из элемента.
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 Type |  Element Type | Тип элемента для поиска. | 
Возвращаться
 Range Element — результат поиска, указывающий положение элемента поиска.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 find Element(elementType, from)
 Ищет в содержимом элемента потомка указанного типа, начиная с указанного Range Element .
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 Type |  Element Type | Тип элемента для поиска. | 
 from |  Range Element | Результат поиска, по которому осуществляется поиск. | 
Возвращаться
 Range Element — результат поиска, указывающий следующую позицию элемента поиска.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 find Text(searchPattern)
Ищет в содержимом элемента указанный текстовый шаблон с помощью регулярных выражений.
Некоторые функции регулярных выражений JavaScript, такие как группы захвата и модификаторы режима, поддерживаются не полностью.
Предоставленный шаблон регулярного выражения независимо сопоставляется с каждым текстовым блоком, содержащимся в текущем элементе.
Параметры
| Имя | Тип | Описание | 
|---|---|---|
 search Pattern |  String | образец для поиска | 
Возвращаться
 Range Element — результат поиска, указывающий позицию искомого текста, или значение NULL, если совпадений нет.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 find Text(searchPattern, from)
Ищет в содержимом элемента указанный текстовый шаблон, начиная с заданного результата поиска.
Некоторые функции регулярных выражений JavaScript, такие как группы захвата и модификаторы режима, поддерживаются не полностью.
Предоставленный шаблон регулярного выражения независимо сопоставляется с каждым текстовым блоком, содержащимся в текущем элементе.
Параметры
| Имя | Тип | Описание | 
|---|---|---|
 search Pattern |  String | образец для поиска | 
 from |  Range Element | результат поиска для поиска | 
Возвращаться
 Range Element — результат поиска, указывающий следующую позицию искомого текста или ноль, если совпадений нет.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 get Attributes()
Получает атрибуты элемента.
 Результатом является объект, содержащий свойство для каждого допустимого атрибута элемента, где каждое имя свойства соответствует элементу в перечислении Document App.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 
 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 — цвет границы, отформатированный в нотации 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 — Ширина границы в пунктах.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 get Cell(rowIndex, cellIndex)
 Извлекает Table Cell по указанным индексам строки и ячейки.
// 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 Index |  Integer | Индекс строки, содержащей извлекаемую ячейку. | 
 cell Index |  Integer | Индекс ячейки, которую нужно получить. | 
Возвращаться
 Table Cell — ячейка таблицы.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
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 Index |  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 Index |  Integer | Индекс столбца. | 
Возвращаться
 Number — Ширина столбца в пунктах.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 get Link Url()
Получает URL-адрес ссылки.
Возвращаться
 String — URL-адрес ссылки или значение NULL, если элемент содержит несколько значений для этого атрибута.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 get Next Sibling()
Извлекает следующий родственный элемент элемента.
Следующий брат имеет того же родителя и следует за текущим элементом.
Возвращаться
 Element — следующий родственный элемент.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
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 Rows . 
// 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 Element — родительский элемент.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 get Previous Sibling()
Извлекает предыдущий родственный элемент элемента.
Предыдущий родственный элемент имеет того же родителя и предшествует текущему элементу.
Возвращаться
 Element — предыдущий родственный элемент.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 get Row(rowIndex)
 Извлекает Table Row по указанному индексу строки. 
// 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 Index |  Integer | Индекс строки, которую нужно получить. | 
Возвращаться
 Table Row — строка таблицы.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
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 App.TextAlignment.NORMAL , Document App.TextAlignment.SUBSCRIPT и Document App.TextAlignment.SUPERSCRIPT .
Возвращаться
 Text Alignment — тип выравнивания текста или null , если текст содержит несколько типов выравнивания текста или если выравнивание текста никогда не устанавливалось.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 get Type()
 Получает Element Type элемента.
 Используйте get Type() чтобы определить точный тип данного элемента. 
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 Type — Тип элемента.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
insert Table Row(childIndex)
 Создает и вставляет новую Table Row по указанному индексу.
Параметры
| Имя | Тип | Описание | 
|---|---|---|
 child Index |  Integer | индекс, по которому вставляется элемент | 
Возвращаться
 Table Row — текущий элемент
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 insert Table Row(childIndex, tableRow)
 Вставляет данную Table Row по указанному индексу.
Параметры
| Имя | Тип | Описание | 
|---|---|---|
 child Index |  Integer | индекс, по которому вставляется элемент | 
 table Row |  Table Row | строка таблицы для вставки | 
Возвращаться
 Table Row — вставленный элемент строки таблицы.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
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 — Удаленный элемент.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 remove Row(rowIndex)
 Удаляет Table Row по указанному индексу строки. 
// 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 Index |  Integer | Индекс строки, которую нужно удалить. | 
Возвращаться
 Table Row — удаленная строка.
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 replace Text(searchPattern, replacement)
Заменяет все вхождения данного текстового шаблона заданной строкой замены, используя регулярные выражения.
Шаблон поиска передается как строка, а не как объект регулярного выражения JavaScript. По этой причине вам необходимо избегать любых обратных косых черт в шаблоне.
В этом методе используется библиотека регулярных выражений Google RE2 , что ограничивает поддерживаемый синтаксис .
Предоставленный шаблон регулярного выражения независимо сопоставляется с каждым текстовым блоком, содержащимся в текущем элементе.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText('^.*Apps ?Script.*$', 'Apps Script');
Параметры
| Имя | Тип | Описание | 
|---|---|---|
 search Pattern |  String | шаблон регулярного выражения для поиска | 
 replacement |  String | текст, который будет использоваться в качестве замены | 
Возвращаться
 Element — текущий элемент
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents 
 set Attributes(attributes)
Устанавливает атрибуты элемента.
 Указанный параметр атрибутов должен быть объектом, в котором каждое имя свойства является элементом перечисления Document App.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 
 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 Index |  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 App.TextAlignment.NORMAL , Document App.TextAlignment.SUBSCRIPT и Document App.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 Alignment |  Text Alignment | тип выравнивания текста, который необходимо применить | 
Возвращаться
 Table — текущий элемент
Авторизация
Сценарии, использующие этот метод, требуют авторизации с одной или несколькими из следующих областей :
-  
https://www.googleapis.com/auth/documents.currentonly -  
https://www.googleapis.com/auth/documents