Zengin metin ve tablo, liste gibi öğeler içeren bir doküman sekmesi.
Document.getTabs()[tabIndex].asDocumentTab() kullanarak bir doküman sekmesini geri getirme
// Get a specific document tab based on the tab ID. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab();
Yöntemler
| Yöntem | Dönüş türü | Kısa açıklama |
|---|---|---|
add | Bookmark | Belirtilen Position konumuna Bookmark ekler. |
add | Footer | Yoksa sekme altbilgi bölümü ekler. |
add | Header | Sekme üstbilgisi bölümü yoksa ekler. |
add | Named | Daha sonra almak için kullanılacak bir ad ve kimliğe sahip Range olan bir Named ekler. |
get | Body | Sekmenin Body değerini alır. |
get | Bookmark|null | Belirtilen kimliğe sahip Bookmark öğesini alır. |
get | Bookmark[] | Sekmedeki tüm Bookmark nesnelerini alır. |
get | Footer | Varsa sekmenin altbilgi bölümünü alır. |
get | Footnote[]|null | Sekmenin gövdesindeki tüm Footnote öğelerini alır. |
get | Header | Varsa sekmenin başlık bölümünü alır. |
get | Named | Belirtilen kimliğe sahip Named öğesini alır. |
get | Named | Sekmedeki tüm Named nesnelerini alır. |
get | Named | Belirtilen ada sahip sekmedeki tüm Named nesnelerini alır. |
new | Position | Sekmedeki bir konuma referans veren yeni bir Position oluşturur. Bu konum, belirli bir öğeye göre belirlenir. |
new | Range | Sekme öğelerinden Range nesneleri oluşturmak için kullanılan bir oluşturucu oluşturur. |
Ayrıntılı belgeler
addBookmark(position)
Belirtilen Position konumuna Bookmark ekler.
// Opens the Docs file and retrieves the tab by its IDs. If you created your // script from within a Google Docs file, you can use // DocumentApp.getActiveDocument().getActiveTab() instead. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); // Gets the tab body and adds a paragraph. const paragraph = documentTab.getBody().appendParagraph('My new paragraph.'); // Creates a position at the first character of the paragraph text. const position = documentTab.newPosition(paragraph.getChild(0), 0); // Adds a bookmark at the first character of the paragraph text. const bookmark = documentTab.addBookmark(position); // Logs the bookmark ID to the console. console.log(bookmark.getId());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
position | Position | Yeni yer işaretinin konumu. |
Return
Bookmark: Yeni yer işareti.
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
addHeader()
Sekme üstbilgisi bölümü yoksa ekler.
// Opens the Docs file and retrieves the tab by its IDs. If you created your // script from within a Google Docs file, you can use // DocumentApp.getActiveDocument().getActiveTab() instead. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); // Adds a header to the tab. const header = documentTab.addHeader(); // Sets the header text to 'This is a header.' header.setText('This is a header');
Return
HeaderSection: Sekme başlığı.
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
addNamedRange(name, range)
Daha sonra almak için kullanılacak bir ad ve kimliğe sahip Range olan bir NamedRange ekler. Adlar, sekmeler arasında bile benzersiz olmak zorunda değildir. Aynı belgedeki birkaç farklı aralık, HTML'deki bir sınıf gibi aynı adı paylaşabilir. Buna karşılık, kimlikler HTML'deki bir kimlik gibi doküman içinde benzersizdir. Eklediğiniz bir NamedRange değiştirilemez, yalnızca kaldırılabilir.
Sekmeye erişen tüm komut dosyaları NamedRange değerine erişebilir. Komut dosyaları arasında istenmeyen çakışmaları önlemek için aralık adlarının önüne benzersiz bir dize ekleyebilirsiniz.
// Creates a named range that includes every table in a tab by its ID. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); const rangeBuilder = documentTab.newRange(); const tables = documentTab.getBody().getTables(); for (let i = 0; i < tables.length; i++) { rangeBuilder.addElement(tables[i]); } documentTab.addNamedRange('Tab t.0 tables', rangeBuilder.build());
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
name | String | Aralığın adı. Benzersiz olması gerekmez. Aralık adları 1-256 karakter arasında olmalıdır. |
range | Range | Adla ilişkilendirilecek öğe aralığı. Aralık, arama sonucu olabilir veya new ile manuel olarak oluşturulabilir. |
Return
NamedRange — NamedRange.
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
getBody()
Sekmenin Body değerini alır.
Sekmeler farklı türlerde bölümler (ör. HeaderSection, FooterSection) içerebilir. Bir sekmenin etkin bölümü Body'dir.
DocumentTab içindeki öğe yöntemleri Body öğesine temsilci olarak atanır.
// Opens the Docs file and retrieves the tab by its IDs. If you created your // script from within a Google Docs file, you can use // DocumentApp.getActiveDocument().getActiveTab() instead. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); // Gets the tab body. const body = documentTab.getBody(); // Gets the body text and logs it to the console. console.log(body.getText());
Return
Body: Sekmenin gövde bölümü.
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
getBookmark(id)
Belirtilen kimliğe sahip Bookmark öğesini alır. Bu sekmede böyle bir Bookmark yoksa bu yöntem null değerini döndürür.
// Opens the Docs file and retrieves the tab by its IDs. If you created your // script from within a Google Docs file, you can use // DocumentApp.getActiveDocument().getActiveTab() instead. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); // Gets the bookmark by its ID. const bookmark = documentTab.getBookmark('id.xyz654321'); // If the bookmark exists within the tab, logs the character offset of its // position to the console. Otherwise, logs 'No bookmark exists with the given // ID.' to the console. if (bookmark) { console.log(bookmark.getPosition().getOffset()); } else { console.log('No bookmark exists with the given ID.'); }
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
id | String | Bookmark için kimlik. |
Return
Bookmark|null: Belirtilen kimliğe sahip Bookmark veya sekmede böyle bir Bookmark 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
getBookmarks()
Sekmedeki tüm Bookmark nesnelerini alır.
// Opens the Docs file and retrieves the tab by its IDs. If you created your // script from within a Google Docs file, you can use // DocumentApp.getActiveDocument().getActiveTab() instead. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); // Gets all of the bookmarks in the tab. const bookmarks = documentTab.getBookmarks(); // Logs the number of bookmarks in the tab to the console. console.log(bookmarks.length);
Return
Bookmark[]: Sekmedeki Bookmark nesnelerinin dizisi.
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
getFootnotes()
Sekmenin gövdesindeki tüm Footnote öğelerini alır.
getFootnotes çağrıları, sekmenin öğeleri üzerinde yinelemeye neden olur. Büyük sekmeler için bu yönteme gereksiz çağrılardan kaçının.
// Opens the Docs file and retrieves the tab by its IDs. If you created your // script from within a Google Docs file, you can use // DocumentApp.getActiveDocument().getActiveTab() instead. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); // Gets the first footnote. const footnote = documentTab.getFootnotes()[0]; // Logs footnote contents to the console. console.log(footnote.getFootnoteContents().getText());
Return
Footnote[]|null: Sekmenin dipnotları.
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
getHeader()
Varsa sekmenin başlık bölümünü alır.
// Opens the Docs file and retrieves the tab by its IDs. If you created your // script from within a Google Docs file, you can use // DocumentApp.getActiveDocument().getActiveTab() instead. // TODO(developer): Replace the IDs with your own. const documentTab = DocumentApp.openById('123abc').getTab('123abc').asDocumentTab(); // Gets the text of the tab's header and logs it to the console. console.log(documentTab.getHeader().getText());
Return
HeaderSection|null: Sekmenin başlığı.
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
getNamedRangeById(id)
Belirtilen kimliğe sahip NamedRange öğesini alır. Bu yöntem, sekmede böyle bir null yoksa NamedRange değerini döndürür. Adlar, sekmeler arasında bile benzersiz olmayabilir. Aynı dokümandaki birkaç farklı aralık, HTML'deki bir sınıf gibi aynı adı paylaşabilir. Buna karşılık, kimlikler HTML'deki bir kimlik gibi sekme içinde benzersizdir.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
id | String | Sekme içinde benzersiz olan aralığın kimliği. |
Return
NamedRange|null: Belirtilen kimliğe sahip NamedRange veya sekmede böyle bir aralık 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
getNamedRanges()
Sekmedeki tüm NamedRange nesnelerini alır.
Bir NamedRange, sekmeye erişen tüm komut dosyaları tarafından kullanılabilir. Komut dosyaları arasında istenmeyen çakışmaları önlemek için aralık adlarının önüne benzersiz bir dize ekleyebilirsiniz.
Return
NamedRange[]: Sekmedeki NamedRange nesnelerinin dizisi. Aynı ada sahip birden fazla aralık içerebilir.
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
getNamedRanges(name)
Belirtilen ada sahip sekmedeki tüm NamedRange nesnelerini alır. Adlar, sekmeler arasında bile benzersiz olmak zorunda değildir. Aynı dokümandaki birkaç farklı aralık, HTML'deki bir sınıf gibi aynı adı paylaşabilir. Buna karşılık, kimlikler sekme içinde benzersizdir (ör. HTML'deki bir kimlik).
Bir NamedRange, sekmeye erişen tüm komut dosyaları tarafından kullanılabilir. Komut dosyaları arasında istenmeyen çakışmaları önlemek için aralık adlarının önüne benzersiz bir dize ekleyebilirsiniz.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
name | String | Aralığın adı (benzersiz olması gerekmez). |
Return
NamedRange[]: Belirtilen ada sahip sekmedeki NamedRange nesnelerinin dizisi.
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
newPosition(element, offset)
Sekmedeki bir konuma referans veren yeni bir Position oluşturur. Bu konum, belirli bir öğeye göre belirlenir. Kullanıcının imleci, diğer kullanımların yanı sıra Position olarak gösterilir.
// Append a paragraph, then place the user's cursor after the first word of the // new paragraph. // TODO(developer): Replace the IDs with your own. const doc = DocumentApp.openById('123abc'); const documentTab = doc.getTab('123abc').asDocumentTab(); const paragraph = documentTab.getBody().appendParagraph('My new paragraph.'); const position = documentTab.newPosition(paragraph.getChild(0), 2); doc.setCursor(position);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
element | Element | Yeni oluşturulan Position öğesini içeren öğe. Bu, Text öğesi veya Paragraph gibi bir kapsayıcı öğe olmalıdır. |
offset | Integer | Text öğeleri için Position öncesindeki karakter sayısı; diğer öğeler için aynı kapsayıcı öğe içindeki Position öncesindeki alt öğe sayısı. |
Return
Position — Yeni Position.
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
newRange()
Sekme öğelerinden Range nesneleri oluşturmak için kullanılan bir oluşturucu oluşturur.
// Change the user's selection to a range that includes every table in the tab. // TODO(developer): Replace the IDs with your own. const doc = DocumentApp.openById('123abc'); const documentTab = doc.getTab('123abc').asDocumentTab(); const rangeBuilder = documentTab.newRange(); const tables = documentTab.getBody().getTables(); for (let i = 0; i < tables.length; i++) { rangeBuilder.addElement(tables[i]); } doc.setSelection(rangeBuilder.build());
Return
RangeBuilder: Yeni derleyici.
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