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 adı ve kimliği olan bir Range olan 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
add Bookmark(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
add Header()
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
Header: 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
add Named Range(name, range)
Daha sonra almak için adı ve kimliği olan bir Range olan Named ekler. Adlar, sekmeler arasında bile benzersiz olmayabilir. 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 Named değiştirilemez, yalnızca kaldırılabilir.
Sekmeye erişen tüm komut dosyaları Named değerine erişebilir. Komut dosyaları arasında istenmeyen çakışmaları önlemek için aralık adlarına benzersiz bir dizeyle önek eklemeyi düşünebilirsiniz.
// 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
Named — Named.
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 Body()
Sekmenin Body değerini alır.
Sekmeler farklı türlerde bölümler (ör. Header, Footer) içerebilir. Bir sekmenin etkin bölümü Body'dir.
Document 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
get Bookmark(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
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ı, 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 Footnotes()
Sekmenin gövdesindeki tüm Footnote öğelerini alır.
get ç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
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ı, 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 Named Range By Id(id)
Belirtilen kimliğe sahip Named öğesini alır. Bu yöntem, sekmede böyle bir null yoksa Named 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
Named: Belirtilen kimliğe sahip Named 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
get Named Ranges()
Sekmedeki tüm Named nesnelerini alır.
Bir Named, 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
Named: Sekmedeki Named 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
get Named Ranges(name)
Belirtilen ada sahip sekmedeki tüm Named 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 Named, 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
Named: Belirtilen ada sahip sekmedeki Named 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
new Position(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 karakterinden önceki karakter sayısı; diğer öğeler için aynı kapsayıcı öğe içindeki Position öğesinden önceki 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
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ı, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents