दस्तावेज़ टैब में, रिच टेक्स्ट और टेबल और सूचियों जैसे एलिमेंट होते हैं.
Document.getTabs()[tabIndex].asDocumentTab() का इस्तेमाल करके, किसी दस्तावेज़ का टैब वापस लाएं.
// 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();
तरीके
| तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
|---|---|---|
add | Bookmark | इस फ़ंक्शन की मदद से, दिए गए Position पर Bookmark जोड़ा जाता है. |
add | Footer | अगर कोई टैब फ़ुटर सेक्शन मौजूद नहीं है, तो यह उसे जोड़ता है. |
add | Header | अगर कोई टैब हेडर सेक्शन मौजूद नहीं है, तो उसे जोड़ता है. |
add | Named | Named जोड़ता है. यह एक Range होता है, जिसका नाम और आईडी होता है. इसका इस्तेमाल बाद में किया जा सकता है. |
get | Body | यह कुकी, टैब का Body वापस पाती है. |
get | Bookmark|null | यह फ़ंक्शन, दिए गए आईडी वाला Bookmark ऑब्जेक्ट दिखाता है. |
get | Bookmark[] | टैब में मौजूद सभी Bookmark ऑब्जेक्ट को ऐक्सेस करता है. |
get | Footer | अगर टैब में फ़ुटर सेक्शन मौजूद है, तो यह फ़ंक्शन उसे वापस लाता है. |
get | Footnote[]|null | यह टैब के मुख्य हिस्से में मौजूद सभी Footnote एलिमेंट को वापस लाता है. |
get | Header | अगर टैब में हेडर सेक्शन मौजूद है, तो यह कुकी उसे वापस लाती है. |
get | Named | यह फ़ंक्शन, दिए गए आईडी वाला Named ऑब्जेक्ट दिखाता है. |
get | Named | टैब में मौजूद सभी Named ऑब्जेक्ट को ऐक्सेस करता है. |
get | Named | इस फ़ंक्शन से, दिए गए नाम वाले टैब में मौजूद सभी Named ऑब्जेक्ट मिलते हैं. |
new | Position | यह एक नया Position बनाता है. यह टैब में किसी जगह का रेफ़रंस होता है. यह रेफ़रंस, किसी खास एलिमेंट के हिसाब से होता है. |
new | Range | यह एक बिल्डर बनाता है. इसका इस्तेमाल, टैब एलिमेंट से Range ऑब्जेक्ट बनाने के लिए किया जाता है. |
ज़्यादा जानकारी वाला दस्तावेज़
add Bookmark(position)
इस फ़ंक्शन की मदद से, दिए गए Position पर Bookmark जोड़ा जाता है.
// 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());
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
position | Position | नए बुकमार्क की जगह. |
वापसी का टिकट
Bookmark — नया बुकमार्क.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
add Header()
अगर कोई टैब हेडर सेक्शन मौजूद नहीं है, तो उसे जोड़ता है.
// 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');
वापसी का टिकट
Header — टैब का हेडर.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
add Named Range(name, range)
Named जोड़ता है. यह एक Range होता है, जिसका नाम और आईडी होता है. इसका इस्तेमाल बाद में किया जा सकता है. नाम ज़रूरी नहीं कि यूनीक हों. यहां तक कि अलग-अलग टैब में भी नाम यूनीक नहीं होते. एक ही दस्तावेज़ में कई अलग-अलग रेंज का नाम एक जैसा हो सकता है. यह एचटीएमएल में क्लास की तरह होता है. इसके उलट, आईडी दस्तावेज़ में यूनीक होते हैं. जैसे, एचटीएमएल में आईडी. Named जोड़ने के बाद, इसमें बदलाव नहीं किया जा सकता. इसे सिर्फ़ हटाया जा सकता है.
टैब को ऐक्सेस करने वाली कोई भी स्क्रिप्ट, Named को ऐक्सेस कर सकती है. स्क्रिप्ट के बीच अनचाहे टकराव से बचने के लिए, रेंज के नामों के आगे कोई यूनीक स्ट्रिंग जोड़ें.
// 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());
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
name | String | रेंज का नाम. यह यूनीक होना ज़रूरी नहीं है. रेंज के नाम में 1 से 256 वर्ण होने चाहिए. |
range | Range | नाम से जोड़ने के लिए एलिमेंट की रेंज; रेंज, खोज का नतीजा हो सकती है या इसे new का इस्तेमाल करके मैन्युअल तरीके से बनाया जा सकता है. |
वापसी का टिकट
Named — Named की टीम.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Body()
यह कुकी, टैब का Body वापस पाती है.
टैब में अलग-अलग तरह के सेक्शन हो सकते हैं. उदाहरण के लिए, Header, Footer. किसी टैब के लिए ऐक्टिव सेक्शन, Body होता है.
Document में मौजूद एलिमेंट के तरीके, Body को सौंपे जाते हैं.
// 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());
वापसी का टिकट
Body — टैब का बॉडी सेक्शन.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Bookmark(id)
यह फ़ंक्शन, दिए गए आईडी वाला Bookmark ऑब्जेक्ट दिखाता है. अगर इस टैब में ऐसा कोई Bookmark मौजूद नहीं है, तो यह तरीका null दिखाता है.
// 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.'); }
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
id | String | Bookmark का आईडी. |
वापसी का टिकट
Bookmark|null — दिए गए आईडी वाला Bookmark या अगर टैब में ऐसा कोई Bookmark मौजूद नहीं है, तो null.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Bookmarks()
टैब में मौजूद सभी Bookmark ऑब्जेक्ट को ऐक्सेस करता है.
// 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);
वापसी का टिकट
Bookmark[] — टैब में मौजूद Bookmark ऑब्जेक्ट का कलेक्शन.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Footnotes()
यह टैब के मुख्य हिस्से में मौजूद सभी Footnote एलिमेंट को वापस लाता है.
get को कॉल करने पर, टैब के एलिमेंट पर बार-बार फ़ोकस होता है. बड़े टैब के लिए, इस तरीके को बेवजह कॉल करने से बचें.
// 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());
वापसी का टिकट
Footnote[]|null — टैब के फ़ुटनोट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Header()
अगर टैब में हेडर सेक्शन मौजूद है, तो यह कुकी उसे वापस लाती है.
// 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());
वापसी का टिकट
Header — टैब का हेडर.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Range By Id(id)
यह फ़ंक्शन, दिए गए आईडी वाला Named ऑब्जेक्ट दिखाता है. अगर टैब में ऐसा कोई Named मौजूद नहीं है, तो यह तरीका null दिखाता है. ज़रूरी नहीं कि नाम यूनीक हों. यहां तक कि अलग-अलग टैब में भी नाम एक जैसे हो सकते हैं;
एक ही दस्तावेज़ में कई अलग-अलग रेंज के नाम एक जैसे हो सकते हैं. यह कुछ हद तक एचटीएमएल में क्लास की तरह होता है. इसके उलट, आईडी टैब में यूनीक होते हैं. जैसे, एचटीएमएल में आईडी.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
id | String | रेंज का आईडी, जो टैब में यूनीक होता है. |
वापसी का टिकट
Named — दिए गए आईडी वाला Named या अगर टैब में ऐसी कोई रेंज मौजूद नहीं है, तो null.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Ranges()
टैब में मौजूद सभी Named ऑब्जेक्ट को ऐक्सेस करता है.
Named को ऐसी कोई भी स्क्रिप्ट ऐक्सेस कर सकती है जो टैब को ऐक्सेस करती है. स्क्रिप्ट के बीच अनचाहे टकराव से बचने के लिए, रेंज के नामों के आगे कोई यूनीक स्ट्रिंग जोड़ें.
वापसी का टिकट
Named — टैब में मौजूद Named ऑब्जेक्ट की एक कलेक्शन. इसमें एक ही नाम वाली कई रेंज शामिल हो सकती हैं.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Named Ranges(name)
इस फ़ंक्शन से, दिए गए नाम वाले टैब में मौजूद सभी Named ऑब्जेक्ट मिलते हैं. ज़रूरी नहीं कि नाम यूनीक हों. यहां तक कि अलग-अलग टैब में भी नाम यूनीक नहीं होते. एक ही दस्तावेज़ में कई अलग-अलग रेंज का नाम एक जैसा हो सकता है. यह एचटीएमएल में क्लास की तरह होता है. इसके उलट, आईडी टैब में यूनीक होते हैं. जैसे, HTML में आईडी.
Named को ऐसी कोई भी स्क्रिप्ट ऐक्सेस कर सकती है जो टैब को ऐक्सेस करती है. स्क्रिप्ट के बीच अनचाहे टकराव से बचने के लिए, रेंज के नामों के आगे कोई यूनीक स्ट्रिंग जोड़ें.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
name | String | रेंज का नाम, जो यूनीक होना ज़रूरी नहीं है. |
वापसी का टिकट
Named — दिए गए नाम वाले टैब में मौजूद Named ऑब्जेक्ट का कलेक्शन.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
new Position(element, offset)
यह एक नया Position बनाता है. यह टैब में किसी जगह का रेफ़रंस होता है. यह रेफ़रंस, किसी खास एलिमेंट के हिसाब से होता है. उपयोगकर्ता के कर्सर को Position के तौर पर दिखाया जाता है. इसके अलावा, इसका इस्तेमाल अन्य कामों के लिए भी किया जाता है.
// 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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
element | Element | यह वह एलिमेंट है जिसमें नया Position to शामिल है. यह Text एलिमेंट या Paragraph जैसे कंटेनर एलिमेंट में से कोई एक होना चाहिए. |
offset | Integer | Text एलिमेंट के लिए, Position से पहले मौजूद वर्णों की संख्या;
अन्य एलिमेंट के लिए, एक ही कंटेनर एलिमेंट में Position से पहले मौजूद चाइल्ड एलिमेंट की संख्या. |
वापसी का टिकट
Position — नया Position.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
new Range()
यह एक बिल्डर बनाता है. इसका इस्तेमाल, टैब एलिमेंट से Range ऑब्जेक्ट बनाने के लिए किया जाता है.
// 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());
वापसी का टिकट
Range — नया बिल्डर.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents