Zengin metin ve tablolar ile listeler gibi öğeler içeren bir doküman sekmesi.
Document.getTabs()[tabIndex].asDocumentTab() simgesini kullanarak bir doküman sekmesini alın.
// 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 bir Bookmark ekler. |
add | Footer | Mevcut değilse bir sekme altbilgi bölümü ekler. |
add | Header | Mevcut değilse bir sekme üstbilgisi bölümü ekler. |
add | Named | Daha sonra almak için kullanılacak bir ad ve kimliğe sahip bir Range olan Named ekler. |
get | Body | Sekmenin Body değerini alır. |
get | Bookmark | 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[] | Sekmenin gövdesinde bulunan 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 | Belirli bir öğeye göre sekmedeki bir konuma referans veren yeni bir Position oluşturur. |
new | Range | Sekme öğelerinden Range nesneleri oluşturmak için kullanılan bir oluşturucu oluşturur. |
Ayrıntılı dokümanlar
add Bookmark(position)
Belirtilen Position konumuna bir 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ının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
add Header()
Mevcut değilse bir sekme üstbilgisi bölümü 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
Header: Sekme başlığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
add Named Range(name, range)
Daha sonra almak için kullanılacak bir ad ve kimliğe sahip bir Range olan Named ekler. Adlar, sekmeler arasında bile benzersiz olmak zorunda değildir. Aynı dokümanda, HTML'deki sınıflara benzer şekilde, birkaç farklı aralık aynı adı paylaşabilir. Buna karşılık, kimlikler HTML'deki kimlikler gibi doküman içinde benzersizdir. Eklediğiniz Named'leri değiştiremez, yalnızca kaldırabilirsiniz.
Sekmeye erişen tüm komut dosyaları Named'e erişebilir. Komut dosyaları arasında istenmeyen çakışmaları önlemek için aralık adlarına benzersiz bir dize ön ekleyerek başlayabilirsiniz.
// 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 uzunluğunda olmalıdır. |
range | Range | Adla ilişkilendirilecek öğe aralığı. Bu aralık bir arama sonucu olabilir veya new ile manuel olarak oluşturulabilir. |
Return
Named: Named.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Body()
Sekmenin Body değerini alır.
Sekmeler farklı bölüm türleri (ör. Header, Footer) içerebilir. Sekmenin etkin bölümü Body'dir.
Document öğe yöntemleri Body'a 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ının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Bookmark(id)
Belirtilen kimliğe sahip Bookmark öğesini alır. Bu sekmede böyle bir Bookmark yoksa bu yöntem null 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 öğesinin kimliği. |
Return
Bookmark: Belirtilen kimliğe sahip Bookmark veya sekmede böyle bir Bookmark yoksa null.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Bookmarks()
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ının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Footnotes()
Sekmenin gövdesinde bulunan tüm Footnote öğelerini alır.
get çağrıları, sekmenin öğeleri üzerinde iterasyona neden olur. Büyük sekmeler için bu yöntemi gereksiz yere çağırmayı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[]: Sekmenin dipnotları.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Header()
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
Header: Sekmenin başlığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Range By Id(id)
Belirtilen kimliğe sahip Named öğesini alır. Sekmede böyle bir Named yoksa bu yöntem null döndürür. Adlar, sekmeler arasında bile benzersiz olmak zorunda değildir. Aynı dokümanda, HTML'deki sınıflara benzer şekilde, birkaç farklı aralık aynı adı paylaşabilir. Buna karşılık, kimlikler HTML'deki kimlikler gibi sekme içinde benzersizdir.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
id | String | Aralıktaki benzersiz kimlik. |
Return
Named: Belirtilen kimliğe sahip Named veya sekmede böyle bir aralık yoksa null.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Ranges()
Sekmedeki tüm Named nesnelerini alır.
Named, sekmeye erişen tüm komut dosyaları tarafından erişilebilir. Komut dosyaları arasında istenmeyen çakışmaları önlemek için aralık adlarına benzersiz bir dize ön eklenebilir.
Return
Named: Sekmedeki Named nesnelerinin dizisidir. Aynı ada sahip birden fazla aralık içerebilir.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Ranges(name)
Belirtilen ada sahip sekmedeki tüm Named nesnelerini alır. Adlar, sekmeler arasında bile benzersiz olmayabilir. Aynı dokümanda birden fazla farklı aralık, HTML'deki sınıflara benzer şekilde aynı adı paylaşabilir. Buna karşılık, kimlikler HTML'deki kimlikler gibi sekme içinde benzersizdir.
Named, sekmeye erişen tüm komut dosyaları tarafından erişilebilir. Komut dosyaları arasında istenmeyen çakışmaları önlemek için aralık adlarına benzersiz bir dize ön eklenebilir.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
name | String | Aralık adı (benzersiz olmayabilir). |
Return
Named: Belirtilen ada sahip sekmedeki Named nesnelerinin dizisi.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
new Position(element, offset)
Belirli bir öğeye göre sekmedeki bir konuma referans veren yeni bir Position oluşturur. 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, bir Text öğesi veya Paragraph gibi bir kapsayıcı öğe olmalıdır. |
offset | Integer | Text öğeleri için Position'den önceki karakter sayısı, diğer öğeler için ise aynı kapsayıcı öğe içinde Position'den önceki alt öğe sayısı. |
Return
Position: Yeni Position.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
new Range()
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
Range: Yeni oluşturucu.
Yetkilendirme
Bu yöntemi kullanan komut dosyalarının aşağıdaki kapsamlardan bir veya daha fazlası için yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents