Class Table

Tablo

Tabloyu temsil eden bir öğe. Bir Table yalnızca TableRow öğeleri içerebilir. Örneğin, Doküman yapısı hakkında daha fazla bilgi edinmek için Google Dokümanlar'ı genişletme kılavuzuna göz atın.

Çok sayıda satır veya hücre içeren bir Table oluştururken şu işlemi yapabilirsiniz: aşağıdaki örnekte gösterildiği gibi bir dize dizisinden alınır.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().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);

Yöntemler

YöntemDönüş türüKısa açıklama
appendTableRow()TableRowYeni bir TableRow oluşturur ve ekler.
appendTableRow(tableRow)TableRowBelirtilen TableRow öğesini ekler.
clear()TableÖğenin içeriğini temizler.
copy()TableGeçerli öğenin ayrılmış, derin bir kopyasını döndürür.
editAsText()TextDüzenleme için geçerli öğenin Text sürümünü alır.
findElement(elementType)RangeElementÖğenin içeriğinde, belirtilen türün bir alt öğesini arar.
findElement(elementType, from)RangeElementÖğenin içeriğinde, belirtilen RangeElement.
findText(searchPattern)RangeElementNormal ifadeler kullanarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar.
findText(searchPattern, from)RangeElementBelirli bir değerden başlayarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar emin olun.
getAttributes()ObjectÖğenin özelliklerini alır.
getBorderColor()StringKenarlık rengini alır.
getBorderWidth()NumberNokta cinsinden kenarlık genişliğini alır.
getCell(rowIndex, cellIndex)TableCellBelirtilen satır ve hücre dizinlerindeki TableCell öğesini alır.
getChild(childIndex)ElementBelirtilen alt dizindeki alt öğeyi alır.
getChildIndex(child)IntegerBelirtilen alt öğe için alt dizini alır.
getColumnWidth(columnIndex)NumberBelirtilen tablo sütununun punto cinsinden genişliğini alır.
getLinkUrl()StringBağlantı URL'sini alır.
getNextSibling()ElementÖğenin sonraki eşdüzey öğeyi alır.
getNumChildren()IntegerAlt öğelerin sayısını alır.
getNumRows()IntegerTableRows sayısını alır.
getParent()ContainerElementÖğenin üst öğesini alır.
getPreviousSibling()ElementÖğenin önceki eşdüzey öğesini alır.
getRow(rowIndex)TableRowBelirtilen satır dizininde TableRow öğesini alır.
getText()StringÖğenin içeriğini bir metin dizesi olarak alır.
getTextAlignment()TextAlignmentMetin hizalamasını getirir.
getType()ElementTypeÖğenin ElementType değerini alır.
insertTableRow(childIndex)TableRowYeni bir TableRow oluşturur ve belirtilen dizine ekler.
insertTableRow(childIndex, tableRow)TableRowVerilen TableRow öğesini belirtilen dizine ekler.
isAtDocumentEnd()BooleanÖğenin, Document öğesinin sonunda olup olmadığını belirler.
removeChild(child)TableBelirtilen alt öğeyi kaldırır.
removeFromParent()TableÖğeyi üst öğesinden kaldırır.
removeRow(rowIndex)TableRowBelirtilen satır dizinindeki TableRow öğesini kaldırır.
replaceText(searchPattern, replacement)ElementBelirli bir metin kalıbının tüm tekrarlarını, normal değer kullanarak belirli bir değiştirme dizesiyle değiştirir ifade eder.
setAttributes(attributes)TableÖğenin özelliklerini ayarlar.
setBorderColor(color)TableKenarlık rengini ayarlar.
setBorderWidth(width)TableKenarlık genişliğini punto olarak ayarlar.
setColumnWidth(columnIndex, width)TableBelirtilen sütunun genişliğini punto olarak ayarlar.
setLinkUrl(url)TableBağlantı URL'sini ayarlar.
setTextAlignment(textAlignment)TableMetin hizalamasını ayarlar.

Ayrıntılı belgeler

appendTableRow()

Yeni bir TableRow oluşturur ve ekler.

Return

TableRow: Yeni tablo satır öğesi

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

appendTableRow(tableRow)

Belirtilen TableRow öğesini ekler.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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);

Parametreler

AdTürAçıklama
tableRowTableRowEklenecek tablo satırı.

Return

TableRow: Eklenen tablo satırı öğesi.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

clear()

Öğenin içeriğini temizler.

Return

Table: Geçerli öğe.


copy()

Geçerli öğenin ayrılmış, derin bir kopyasını döndürür.

Öğede bulunan tüm alt öğeler de kopyalanır. Yeni öğede üst öğesidir.

Return

Table — Yeni kopya.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

editAsText()

Düzenleme için geçerli öğenin Text sürümünü alır.

Öğe içeriklerini zengin metin olarak değiştirmek için editAsText kullanın. editAsText modu, metin olmayan öğeleri (InlineImage ve HorizontalRule gibi) yoksayar.

Silinmiş bir metin aralığında tamamen yer alan alt öğeler öğeden kaldırılır.

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

Return

Text: Geçerli öğenin metin sürümü


findElement(elementType)

Öğenin içeriğinde, belirtilen türün bir alt öğesini arar.

Parametreler

AdTürAçıklama
elementTypeElementTypeAranacak öğenin türü.

Return

RangeElement: Arama öğesinin konumunu gösteren bir arama sonucu.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

findElement(elementType, from)

Öğenin içeriğinde, belirtilen RangeElement.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().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;
  }
}

Parametreler

AdTürAçıklama
elementTypeElementTypeAranacak öğenin türü.
fromRangeElementArama yapılacak arama sonucu.

Return

RangeElement: Arama öğesinin sonraki konumunu gösteren arama sonucu.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

findText(searchPattern)

Normal ifadeler kullanarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar.

JavaScript normal ifade özelliklerinin bir alt kümesi tam olarak desteklenmiyor; örneğin, ve mod değiştiricileri yakalayabilirsiniz.

Sağlanan normal ifade kalıbı her metin bloğuyla bağımsız olarak eşleştirilir öğedir.

Parametreler

AdTürAçıklama
searchPatternStringaranacak kalıp

Return

RangeElement — arama metninin konumunu veya konumunu gösteren bir arama sonucu yoksa null denk gelmek

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

findText(searchPattern, from)

Belirli bir değerden başlayarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar emin olun.

JavaScript normal ifade özelliklerinin bir alt kümesi tam olarak desteklenmiyor; örneğin, ve mod değiştiricileri yakalayabilirsiniz.

Sağlanan normal ifade kalıbı her metin bloğuyla bağımsız olarak eşleştirilir öğedir.

Parametreler

AdTürAçıklama
searchPatternStringaranacak kalıp
fromRangeElementarama sonuçlarında

Return

RangeElement — arama metninin sonraki konumunu gösteren bir arama sonucu veya denk gelmek

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getAttributes()

Öğenin özelliklerini alır.

Sonuç, her bir geçerli öğe özelliği için bir özellik içeren özellik adı, DocumentApp.Attribute numaralandırmasındaki bir öğeye karşılık gelir.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.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]);
}

Return

Object: Öğenin özellikleri.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getBorderColor()

Kenarlık rengini alır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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());

Return

String — CSS gösteriminde biçimlendirilmiş kenarlık rengi ('#ffffff' gibi).

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getBorderWidth()

Nokta cinsinden kenarlık genişliğini alır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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());

Return

Number — Nokta cinsinden kenarlık genişliği.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getCell(rowIndex, cellIndex)

Belirtilen satır ve hücre dizinlerindeki TableCell öğesini alır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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());

Parametreler

AdTürAçıklama
rowIndexIntegerAlınacak hücreyi içeren satırın dizini.
cellIndexIntegerAlınacak hücrenin dizini.

Return

TableCell: Tablo hücresi.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getChild(childIndex)

Belirtilen alt dizindeki alt öğeyi alır.

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

// Obtain the first element in the tab.
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.");
}

Parametreler

AdTürAçıklama
childIndexIntegerAlınacak alt öğenin dizini.

Return

Element: Belirtilen dizindeki alt öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getChildIndex(child)

Belirtilen alt öğe için alt dizini alır.

Parametreler

AdTürAçıklama
childElementDizinin alınacağı alt öğe.

Return

Integer — Alt dizin.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getColumnWidth(columnIndex)

Belirtilen tablo sütununun punto cinsinden genişliğini alır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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));

Parametreler

AdTürAçıklama
columnIndexIntegerSütun dizini.

Return

Number: Nokta cinsinden sütun genişliği.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getLinkUrl()

Bağlantı URL'sini alır.

Return

String: bağlantı URL'si veya öğe bu özellik için birden fazla değer içeriyorsa null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getNextSibling()

Öğenin sonraki eşdüzey öğeyi alır.

Sonraki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeyi takip eder.

Return

Element: Sonraki kardeş öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getNumChildren()

Alt öğelerin sayısını alır.

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

Return

Integer — Alt öğelerin sayısı.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getNumRows()

TableRows sayısını alır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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());

Return

Integer: Tablo satırlarının sayısıdır.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getParent()

Öğenin üst öğesini alır.

Üst öğe, geçerli öğeyi içeriyor.

Return

ContainerElement: Üst öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getPreviousSibling()

Öğenin önceki eşdüzey öğesini alır.

Önceki eşdüzey öğe, aynı üst öğeye sahip ve geçerli öğeden önce geliyor.

Return

Element: Önceki kardeş öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getRow(rowIndex)

Belirtilen satır dizininde TableRow öğesini alır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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());

Parametreler

AdTürAçıklama
rowIndexIntegerAlınacak satırın dizini.

Return

TableRow: Tablo satırı.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getText()

Öğenin içeriğini bir metin dizesi olarak alır.

Return

String: Metin dizesi olarak öğenin içeriği

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getTextAlignment()

Metin hizalamasını getirir. Kullanılabilir hizalama türleri şunlardır: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT ve DocumentApp.TextAlignment.SUPERSCRIPT.

Return

TextAlignment: Metin hizalamasının türü veya metin birden fazla metin türü içeriyorsa null veya metin hizalaması hiç ayarlanmamışsa

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

getType()

Öğenin ElementType değerini alır.

Belirli bir öğenin tam türünü belirlemek için getType() işlevini kullanın.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Obtain the first element in the active tab's 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.');
}

Return

ElementType: Öğe türü.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

insertTableRow(childIndex)

Yeni bir TableRow oluşturur ve belirtilen dizine ekler.

Parametreler

AdTürAçıklama
childIndexIntegeröğenin ekleneceği dizin

Return

TableRow - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

insertTableRow(childIndex, tableRow)

Verilen TableRow öğesini belirtilen dizine ekler.

Parametreler

AdTürAçıklama
childIndexIntegeröğenin ekleneceği dizin
tableRowTableRoweklenecek tablo satırı

Return

TableRow: Eklenen tablo satırı öğesi

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

isAtDocumentEnd()

Öğenin, Document öğesinin sonunda olup olmadığını belirler.

Return

Boolean — Öğenin sekmenin sonunda olup olmadığı.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

removeChild(child)

Belirtilen alt öğeyi kaldırır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').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());

Parametreler

AdTürAçıklama
childElementKaldırılacak alt öğe.

Return

Table: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

removeFromParent()

Öğeyi üst öğesinden kaldırır.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab()
var body = documentTab.getBody();

// Remove all images in the active tab's body.
var imgs = body.getImages();
for (var i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}

Return

Table: Kaldırılan öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

removeRow(rowIndex)

Belirtilen satır dizinindeki TableRow öğesini kaldırır.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Gets the first table and removes its second row.
const table = body.getTables()[0];
table.removeRow(1);

Parametreler

AdTürAçıklama
rowIndexIntegerKaldırılacak satırın dizini.

Return

TableRow: Kaldırılan satır.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

replaceText(searchPattern, replacement)

Belirli bir metin kalıbının tüm tekrarlarını, normal değer kullanarak belirli bir değiştirme dizesiyle değiştirir ifade eder.

Arama kalıbı, JavaScript normal ifade nesnesi değil, dize olarak iletilir. Bu nedenle, kalıptaki ters eğik çizgilerden kaçınmanız gerekir.

Bu yöntemler, Google'ın normal RE2 desteklenen söz dizimini sınırlayan ifade kitaplığı için kullanılır.

Sağlanan normal ifade kalıbı her metin bloğuyla bağımsız olarak eşleştirilir öğedir.

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

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

Parametreler

AdTürAçıklama
searchPatternStringaranacak normal ifade kalıbı
replacementStringyerine kullanılacak metin

Return

Element - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

setAttributes(attributes)

Öğenin özelliklerini ayarlar.

Belirtilen özellikler parametresi, her özellik adının DocumentApp.Attribute sıralaması ve her özellik değeri, geçerlidir.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.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);

Parametreler

AdTürAçıklama
attributesObjectÖğenin özellikleri.

Return

Table: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

setBorderColor(color)

Kenarlık rengini ayarlar.

// 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 body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Gets the first table.
const table = body.getTables()[0];

// Sets the border color of the table to green.
table.setBorderColor('#00FF00');

Parametreler

AdTürAçıklama
colorStringCSS gösteriminde biçimlendirilmiş kenarlık rengi ('#ffffff' gibi).

Return

Table: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

setBorderWidth(width)

Kenarlık genişliğini punto olarak ayarlar.

Parametreler

AdTürAçıklama
widthNumberpunto olarak kenarlık genişliği

Return

Table - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

setColumnWidth(columnIndex, width)

Belirtilen sütunun genişliğini punto olarak ayarlar.

Parametreler

AdTürAçıklama
columnIndexIntegersütun dizini
widthNumberpunto olarak kenarlık genişliği

Return

Table - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

setLinkUrl(url)

Bağlantı URL'sini ayarlar.

Parametreler

AdTürAçıklama
urlStringbağlantı URL'si

Return

Table - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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

setTextAlignment(textAlignment)

Metin hizalamasını ayarlar. Kullanılabilir hizalama türleri şunlardır: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT ve DocumentApp.TextAlignment.SUPERSCRIPT.

// Make the entire first paragraph in the active tab be superscript.
var documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
var text = documentTab.getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);

Parametreler

AdTürAçıklama
textAlignmentTextAlignmentuygulanacak metin hizalamasının türü

Return

Table - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

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