Tabloyu temsil eden bir öğe. Bir Table
yalnızca TableRow
öğeleri içerebilir. Doküman yapısı hakkında daha fazla bilgi için Google Dokümanlar'ın kapsamını genişletme kılavuzuna bakın.
Çok sayıda satır veya hücre içeren bir Table
oluştururken, bunu aşağıdaki örnekte gösterildiği gibi bir dize dizisinden oluşturmayı düşünün.
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);
Yöntemler
Yöntem | Dönüş türü | Kısa açıklama |
---|---|---|
appendTableRow() | TableRow | Yeni bir TableRow oluşturup ekler. |
appendTableRow(tableRow) | TableRow | Belirtilen TableRow dizesini ekler. |
clear() | Table | Öğenin içeriğini temizler. |
copy() | Table | Geçerli öğenin ayrı, derin bir kopyasını döndürür. |
editAsText() | Text | Düzenleme için geçerli öğenin Text sürümünü alır. |
findElement(elementType) | RangeElement | Öğenin içeriğinde, belirtilen türde bir alt öğe arar. |
findElement(elementType, from) | RangeElement | Belirtilen RangeElement öğesinden başlayarak, öğenin içeriğinde belirtilen türde bir alt öğe arar. |
findText(searchPattern) | RangeElement | Normal ifadeler kullanarak, belirtilen metin kalıbı için öğenin içeriğinde arama yapar. |
findText(searchPattern, from) | RangeElement | Belirli bir arama sonucundan başlayarak, belirtilen metin kalıbı için öğenin içeriğinde arama yapar. |
getAttributes() | Object | Öğenin özelliklerini alır. |
getBorderColor() | String | Kenarlık rengini alır. |
getBorderWidth() | Number | Kenarlık genişliğini punto cinsinden alır. |
getCell(rowIndex, cellIndex) | TableCell | Belirtilen satır ve hücre dizinlerinde TableCell öğesini getirir. |
getChild(childIndex) | Element | Belirtilen alt dizindeki alt öğeyi alır. |
getChildIndex(child) | Integer | Belirtilen alt öğe için alt dizini alır. |
getColumnWidth(columnIndex) | Number | Belirtilen tablo sütununun genişliğini nokta cinsinden alır. |
getLinkUrl() | String | Bağlantı URL'sini alır. |
getNextSibling() | Element | Öğenin sonraki eşdüzey öğesini alır. |
getNumChildren() | Integer | Alt öğe sayısını alır. |
getNumRows() | Integer | TableRows sayısını getirir. |
getParent() | ContainerElement | Öğenin üst öğesini alır. |
getPreviousSibling() | Element | Öğenin önceki eşdüzey öğesini alır. |
getRow(rowIndex) | TableRow | Belirtilen satır dizininde TableRow öğesini getirir. |
getText() | String | Öğenin içeriğini metin dizesi olarak alır. |
getTextAlignment() | TextAlignment | Metin hizalamasını sağlar. |
getType() | ElementType | Öğenin ElementType değerini alır. |
insertTableRow(childIndex) | TableRow | Belirtilen dizinde yeni bir TableRow oluşturur ve ekler. |
insertTableRow(childIndex, tableRow) | TableRow | Belirtilen TableRow öğesini belirtilen dizine ekler. |
isAtDocumentEnd() | Boolean | Öğenin, Document öğesinin sonunda olup olmadığını belirler. |
removeChild(child) | Table | Belirtilen alt öğeyi kaldırır. |
removeFromParent() | Table | Öğeyi üst öğesinden kaldırır. |
removeRow(rowIndex) | TableRow | Belirtilen satır dizinindeki TableRow öğesini kaldırır. |
replaceText(searchPattern, replacement) | Element | Normal ifadeler kullanarak belirli bir metin kalıbının tüm tekrarlarını verilen bir yeni dizeyle değiştirir. |
setAttributes(attributes) | Table | Öğenin özelliklerini ayarlar. |
setBorderColor(color) | Table | Kenarlık rengini ayarlar. |
setBorderWidth(width) | Table | Kenarlık genişliğini punto cinsinden ayarlar. |
setColumnWidth(columnIndex, width) | Table | Belirtilen sütunun genişliğini punto cinsinden ayarlar. |
setLinkUrl(url) | Table | Bağlantı URL'sini ayarlar. |
setTextAlignment(textAlignment) | Table | Metin hizalamasını ayarlar. |
Ayrıntılı belgeler
appendTableRow()
Yeni bir TableRow
oluşturup ekler.
Return
TableRow
: Yeni tablo satırı öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendTableRow(tableRow)
Belirtilen TableRow
dizesini 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 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);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
tableRow | TableRow | Eklenecek tablo satırı. |
Return
TableRow
: Eklenen tablo satırı öğesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
clear()
copy()
Geçerli öğenin ayrı, derin bir kopyasını döndürür.
Öğede bulunan alt öğeler de kopyalanır. Yeni öğenin bir üst öğesi yoktur.
Return
Table
: Yeni kopya.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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.
Tamamen silinmiş bir metin aralığı içinde yer alan alt öğeler öğeden kaldırılır.
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);
Return
Text
: Geçerli öğenin metin sürümü
findElement(elementType)
Öğenin içeriğinde, belirtilen türde bir alt öğe arar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
elementType | ElementType | aranacak öğe türü |
Return
RangeElement
: Arama öğesinin konumunu belirten arama sonucu
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findElement(elementType, from)
Belirtilen RangeElement
öğesinden başlayarak, öğenin içeriğinde belirtilen türde bir alt öğe arar.
// 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; } }
Parametreler
Ad | Tür | Açıklama |
---|---|---|
elementType | ElementType | aranacak öğe türü |
from | RangeElement | arama yapılacak arama sonucunu |
Return
RangeElement
: Arama öğesinin sonraki konumunu belirten arama sonucu
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 (ör. yakalama grupları ve mod değiştiricileri) tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, geçerli öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
searchPattern | String | mola vermek için |
Return
RangeElement
: Arama metninin konumunu gösteren arama sonucu veya eşleşme yoksa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
Belirli bir arama sonucundan başlayarak, belirtilen metin kalıbı için öğenin içeriğinde arama yapar.
JavaScript normal ifade özelliklerinin bir alt kümesi (ör. yakalama grupları ve mod değiştiricileri) tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, geçerli öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
searchPattern | String | mola vermek için |
from | RangeElement | arama yapılacak arama sonucunu |
Return
RangeElement
: Arama metninin sonraki konumunu veya eşleşme yoksa null değerini gösteren arama sonucu
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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ç, geçerli her öğe özelliği için bir özellik içeren bir nesnedir. Burada her özellik adı, DocumentApp.Attribute
numaralandırmasındaki bir öğeye karşılık gelir.
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]); }
Return
Object
: Öğenin özellikleridir.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 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());
Return
String
: CSS gösteriminde biçimlendirilmiş kenarlık rengi ('#ffffff'
gibi).
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getBorderWidth()
Kenarlık genişliğini punto cinsinden 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 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());
Return
Number
: Nokta cinsinden kenarlık genişliği.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 dizinlerinde TableCell
öğesini getirir.
// 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());
Parametreler
Ad | Tür | Açıklama |
---|---|---|
rowIndex | Integer | Alınacak hücreyi içeren satırın dizini. |
cellIndex | Integer | Alınacak hücrenin dizini. |
Return
TableCell
: Tablo hücresi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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.
// 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."); }
Parametreler
Ad | Tür | Açıklama |
---|---|---|
childIndex | Integer | alt öğenin dizini |
Return
Element
- belirtilen dizindeki alt öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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
Ad | Tür | Açıklama |
---|---|---|
child | Element | dizini alınacak alt öğe |
Return
Integer
- alt dizin
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 genişliğini nokta cinsinden 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 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));
Parametreler
Ad | Tür | Açıklama |
---|---|---|
columnIndex | Integer | Sütun dizini. |
Return
Number
: Nokta cinsinden sütun genişliği.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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; öğe, bu özellik için birden fazla değer içeriyorsa null ifadesini içerir.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 öğesini alır.
Bir sonraki kardeş 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 kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNumChildren()
Alt öğe sayısını alır.
// 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.");
Return
Integer
- çocuk sayısı
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNumRows()
TableRows
sayısını getirir.
// 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());
Return
Integer
: Tablo satırlarının sayısı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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çerir.
Return
ContainerElement
: Üst öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 sahiptir ve geçerli öğeden önce gelir.
Return
Element
: Önceki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 getirir.
// 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());
Parametreler
Ad | Tür | Açıklama |
---|---|---|
rowIndex | Integer | Alınacak satırın dizini. |
Return
TableRow
: Tablo satırı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getText()
Öğenin içeriğini metin dizesi olarak alır.
Return
String
: Metin dizesi olarak öğenin içeriği
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTextAlignment()
Metin hizalamasını sağlar. 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 çok türde metin hizalaması içeriyorsa ya da metin hizalaması hiç ayarlanmadıysa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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()
kullanın.
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.'); }
Return
ElementType
: Öğe türü.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertTableRow(childIndex)
Belirtilen dizinde yeni bir TableRow
oluşturur ve ekler.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
Return
TableRow
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertTableRow(childIndex, tableRow)
Belirtilen TableRow
öğesini belirtilen dizine ekler.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
tableRow | TableRow | eklenecek tablo satırı |
Return
TableRow
: Eklenen tablo satırı öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 dokümanın sonunda olup olmadığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 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());
Parametreler
Ad | Tür | Açıklama |
---|---|---|
child | Element | Kaldırılacak alt öğe. |
Return
Table
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 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(); }
Return
Table
: Kaldırılan öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 document body. const body = doc.getBody(); // Gets the first table and removes its second row. const table = body.getTables()[0]; table.removeRow(1);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
rowIndex | Integer | Kaldırılacak satırın dizini. |
Return
TableRow
: Kaldırılan satır.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
replaceText(searchPattern, replacement)
Normal ifadeler kullanarak belirli bir metin kalıbının tüm tekrarlarını verilen bir yeni dizeyle değiştirir.
Arama kalıbı bir JavaScript normal ifade nesnesi olarak değil, bir dize olarak iletilir. Bu nedenle, kalıptaki ters eğik çizgileri kod dışına almanız gerekir.
Bu yöntem, Google'ın RE2 normal ifade kitaplığını kullanır. Bu kitaplık, desteklenen söz dizimini sınırlar.
Sağlanan normal ifade kalıbı, geçerli öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
var body = DocumentApp.getActiveDocument().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText("^.*Apps ?Script.*$", "Apps Script");
Parametreler
Ad | Tür | Açıklama |
---|---|---|
searchPattern | String | normal ifade kalıbını |
replacement | String | metin yerine |
Return
Element
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 özellik parametresi, her özellik adının DocumentApp.Attribute
numaralandırmasındaki bir öğe ve her özellik değerinin ise uygulanacak yeni değer olduğu bir nesne olmalıdır.
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);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
attributes | Object | Öğenin özellikleri. |
Return
Table
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 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');
Parametreler
Ad | Tür | Açıklama |
---|---|---|
color | String | CSS gösteriminde biçimlendirilmiş kenarlık rengi ('#ffffff' gibi). |
Return
Table
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 cinsinden ayarlar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
width | Number | punto cinsinden kenarlık genişliği |
Return
Table
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 cinsinden ayarlar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
columnIndex | Integer | sütun dizini |
width | Number | punto cinsinden kenarlık genişliği |
Return
Table
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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
Ad | Tür | Açıklama |
---|---|---|
url | String | bağlantı URL'si |
Return
Table
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri 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 be superscript. var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
textAlignment | TextAlignment | uygulanacak metin hizalamasının türü |
Return
Table
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamların biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents