Tabloyu temsil eden bir öğe. Table yalnızca Table öğeleri içerebilir. Belge yapısı hakkında daha fazla bilgi için Google Dokümanlar'ı genişletme rehberine bakın.
Çok sayıda satır veya hücre içeren bir Table oluştururken aşağıdaki örnekte gösterildiği gibi bunu bir dize dizisinden oluşturmayı düşünebilirsiniz.
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);
Yöntemler
| Yöntem | Dönüş türü | Kısa açıklama |
|---|---|---|
append | Table | Yeni bir Table oluşturur ve ekler. |
append | Table | Belirtilen Table eklenir. |
clear() | Table | Öğenin içeriğini temizler. |
copy() | Table | Geçerli öğenin ayrılmış, derin bir kopyasını döndürür. |
edit | Text | Düzenlemek için mevcut öğenin Text sürümünü alır. |
find | Range | Öğenin içeriğinde, belirtilen türde bir alt öğe arar. |
find | Range | Belirtilen Range ile başlayarak, belirtilen türde bir alt öğe için öğenin içeriğini arar. |
find | Range | Normal ifadeleri kullanarak öğenin içeriğinde belirtilen metin kalıbını arar. |
find | Range | Belirtilen metin kalıbını, belirli bir arama sonucundan başlayarak öğenin içeriğinde arar. |
get | Object | Öğenin özelliklerini alır. |
get | String|null | Kenarlık rengini alır. |
get | Number|null | Kenarlık genişliğini punto cinsinden alır. |
get | Table | Belirtilen satır ve hücre dizinlerindeki Table değerini alır. |
get | Element | Belirtilen alt dizindeki alt öğeyi alır. |
get | Integer | Belirtilen alt öğenin alt dizinini alır. |
get | Number|null | Belirtilen tablo sütununun genişliğini puan cinsinden alır. |
get | String|null | Bağlantı URL'sini alır. |
get | Element|null | Öğenin sonraki kardeş öğesini alır. |
get | Integer | Çocuk sayısını alır. |
get | Integer | Table sayısını alır. |
get | Container | Öğenin üst öğesini alır. |
get | Element|null | Öğenin önceki kardeş öğesini alır. |
get | Table | Belirtilen satır dizinindeki Table değerini alır. |
get | String | Öğenin içeriğini metin dizesi olarak alır. |
get | Text | Metin hizalamasını alır. |
get | Element | Öğenin Element değerini alır. |
insert | Table | Belirtilen dizinde yeni bir Table oluşturur ve ekler. |
insert | Table | Belirtilen dizine verilen Table öğesini ekler. |
is | Boolean | Öğenin Document sonunda olup olmadığını belirler. |
remove | Table | Belirtilen alt öğeyi kaldırır. |
remove | Table|null | Öğeyi üst öğesinden kaldırır. |
remove | Table | Belirtilen satır dizinindeki Table öğesini kaldırır. |
replace | Element | Normal ifadeleri kullanarak belirli bir metin kalıbının tüm örneklerini belirli bir yeni dizeyle değiştirir. |
set | Table | Öğenin özelliklerini ayarlar. |
set | Table | Kenarlık rengini ayarlar. |
set | Table | Kenarlık genişliğini punto cinsinden ayarlar. |
set | Table | Belirtilen sütunun genişliğini punto cinsinden ayarlar. |
set | Table | Bağlantı URL'sini ayarlar. |
set | Table | Metin hizalamasını ayarlar. |
Ayrıntılı belgeler
append Table Row()
Yeni bir Table oluşturur ve ekler.
Return
Table: Yeni tablo satırı öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
append Table Row(tableRow)
Belirtilen Table eklenir.
// 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);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
table | Table | Eklenecek tablo satırı. |
Return
Table: Eklenen tablo satırı öğesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan 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ılmış, derin bir kopyasını döndürür.
Öğede bulunan tüm alt öğeler de kopyalanır. Yeni öğenin üst öğesi yok.
Return
Table: Yeni kopya.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
edit As Text()
Düzenlemek için mevcut öğenin Text sürümünü alır.
Öğelerin içeriğini zengin metin olarak değiştirmek için edit kullanın. edit modu, metin olmayan öğeleri (ör. Inline ve Horizontal) yoksayar.
Silinen bir metin aralığında tamamen yer alan alt öğeler, öğeden kaldırılır.
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);
Return
Text: Geçerli öğenin metin sürümü
find Element(elementType)
Öğenin içeriğinde, belirtilen türde bir alt öğe arar.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
element | Element | Aranacak öğe türü. |
Return
Range: Arama öğesinin konumunu gösteren bir arama sonucu.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Element(elementType, from)
Belirtilen Range ile başlayarak, belirtilen türde bir alt öğe için öğenin içeriğini arar.
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; } }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
element | Element | Aranacak öğe türü. |
from | Range | Arama yapılacak arama sonucu. |
Return
Range: Arama öğesinin sonraki konumunu gösteren bir arama sonucu.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern)
Normal ifadeleri kullanarak öğenin içeriğinde belirtilen metin kalıbını arar.
JavaScript normal ifade özelliklerinin bir alt kümesi (ör. yakalama grupları ve mod değiştiriciler) tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, mevcut öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
search | String | Aranacak desen |
Return
Range — arama metninin konumunu gösteren bir arama sonucu veya eşleşme yoksa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern, from)
Belirtilen metin kalıbını, belirli bir arama sonucundan başlayarak öğenin içeriğinde arar.
JavaScript normal ifade özelliklerinin bir alt kümesi (ör. yakalama grupları ve mod değiştiriciler) tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, mevcut öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
search | String | Aranacak desen |
from | Range | Arama yapılacak arama sonucu |
Return
Range: Arama metninin bir sonraki konumunu gösteren bir arama sonucu veya eşleşme yoksa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes()
Öğenin özelliklerini alır.
Sonuç, her geçerli öğe özelliği için bir özellik içeren bir nesnedir. Her özellik adı, Document numaralandırmasındaki bir öğeye karşılık gelir.
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]}`); }
Return
Object: Öğenin özellikleri.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Border Color()
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('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());
Return
String|null: CSS gösterimiyle (ör. '#ffffff') biçimlendirilmiş kenarlık rengi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Border Width()
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('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());
Return
Number|null: Kenarlık genişliği (punto cinsinden).
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Cell(rowIndex, cellIndex)
Belirtilen satır ve hücre dizinlerindeki Table değerini 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('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());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
row | Integer | Alınacak hücreyi içeren satırın dizini. |
cell | Integer | Alınacak hücrenin dizini. |
Return
Table: Tablo hücresi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Child(childIndex)
Belirtilen alt dizindeki alt öğeyi alır.
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.'); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
child | Integer | Alınacak alt öğenin dizini. |
Return
Element: Belirtilen dizindeki alt öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Child Index(child)
Belirtilen alt öğenin alt dizinini alır.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
child | Element | Dizinin alınacağı alt öğe. |
Return
Integer: Çocuk dizini.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Column Width(columnIndex)
Belirtilen tablo sütununun genişliğini puan 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('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));
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
column | Integer | Sütun dizini. |
Return
Number|null: Sütun genişliği (punto cinsinden).
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url()
Bağlantı URL'sini alır.
Return
String|null: 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 biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Next Sibling()
Öğenin sonraki kardeş öğesini alır.
Bir sonraki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeyi takip eder.
Return
Element|null: Sonraki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Num Children()
Çocuk sayısını alır.
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.`);
Return
Integer: Çocuk sayısı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Num Rows()
Table 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('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());
Return
Integer: Tablo satırlarının sayısı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Parent()
Öğenin üst öğesini alır.
Üst öğe, geçerli öğeyi içerir.
Return
Container: Üst öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Previous Sibling()
Öğenin önceki kardeş öğesini alır.
Önceki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeden önce gelir.
Return
Element|null: Önceki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Row(rowIndex)
Belirtilen satır dizinindeki Table değerini 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('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());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
row | Integer | Alınacak satırın dizini. |
Return
Table: Tablo satırı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text()
Öğenin içeriğini metin dizesi olarak alır.
Return
String: Öğenin metin dizesi olarak içeriği
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment()
Metin hizalamasını alır. Kullanılabilir hizalama türleri Document, Document ve Document'dir.
Return
Text: Metin hizalama türü veya metin birden fazla metin hizalama türü içeriyorsa ya da metin hizalama hiç ayarlanmamışsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Type()
Öğenin Element değerini alır.
Belirli bir öğenin tam türünü belirlemek için get kullanın.
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.'); }
Return
Element: Öğe türü.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Table Row(childIndex)
Belirtilen dizinde yeni bir Table oluşturur ve ekler.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
child | Integer | öğenin ekleneceği dizin |
Return
Table: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Table Row(childIndex, tableRow)
Belirtilen dizine verilen Table öğesini ekler.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
child | Integer | öğenin ekleneceği dizin |
table | Table | eklenecek tablo satırı |
Return
Table: Eklenen tablo satırı öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is At Document End()
Öğenin Document sonunda olup olmadığını belirler.
Return
Boolean: Öğenin sekmenin sonunda olup olmadığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Child(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('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());
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 kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove From Parent()
Öğeyi üst öğesinden kaldırır.
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(); }
Return
Table|null: Kaldırılan öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Row(rowIndex)
Belirtilen satır dizinindeki Table öğ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('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);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
row | Integer | Kaldırılacak satırın dizini. |
Return
Table: Kaldırılan satır.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
replace Text(searchPattern, replacement)
Normal ifadeleri kullanarak belirli bir metin kalıbının tüm örneklerini belirli bir yeni dizeyle değiştirir.
Arama kalıbı, JavaScript normal ifade nesnesi olarak değil, dize olarak iletilir. Bu nedenle, desendeki tüm ters eğik çizgileri çıkış karakteriyle belirtmeniz gerekir.
Bu yöntem, desteklenen söz dizimini sınırlayan Google'ın RE2 normal ifade kitaplığını kullanır.
Sağlanan normal ifade kalıbı, mevcut öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText('^.*Apps ?Script.*$', 'Apps Script');
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
search | String | Aranacak normal ifade kalıbı |
replacement | String | Değiştirme için kullanılacak metin |
Return
Element: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Attributes(attributes)
Öğenin özelliklerini ayarlar.
Belirtilen özellikler parametresi, her özellik adının Document numaralandırmasındaki bir öğe ve her özellik değerinin uygulanacak yeni değer olduğu bir nesne olmalıdır.
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);
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 kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Border Color(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('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');
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
color | String | CSS gösterimiyle (ör. '#ffffff') biçimlendirilmiş kenarlık rengi. |
Return
Table: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Border Width(width)
Kenarlık genişliğini punto cinsinden ayarlar.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
width | Number | kenarlık genişliği (punto cinsinden) |
Return
Table: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Column Width(columnIndex, width)
Belirtilen sütunun genişliğini punto cinsinden ayarlar.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
column | Integer | sütun dizini |
width | Number | kenarlık genişliği (punto cinsinden) |
Return
Table: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Link Url(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 kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text Alignment(textAlignment)
Metin hizalamasını ayarlar. Kullanılabilir hizalama türleri Document, Document ve Document'dir.
// 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);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
text | Text | Uygulanacak metin hizalama türü |
Return
Table: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents