टेबल दिखाने वाला एलिमेंट. Table में सिर्फ़ Table एलिमेंट हो सकते हैं. दस्तावेज़ के स्ट्रक्चर के बारे में ज़्यादा जानने के लिए, Google Docs को एक्सटेंड करने से जुड़ी गाइड देखें.
अगर आपको ऐसा Table बनाना है जिसमें बहुत सारी पंक्तियां या सेल शामिल हों, तो उसे स्ट्रिंग कलेक्शन से बनाएं. यहां दिए गए उदाहरण में बताया गया है कि ऐसा कैसे किया जाता है.
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);
तरीके
| तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
|---|---|---|
append | Table | यह एक नया Table बनाता है और उसे जोड़ता है. |
append | Table | यह दिए गए Table को जोड़ता है. |
clear() | Table | इस तरीके से, एलिमेंट का कॉन्टेंट मिट जाता है. |
copy() | Table | यह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है. |
edit | Text | बदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है. |
find | Range | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में, तय किए गए टाइप के डिसेंडेंट को खोजता है. |
find | Range | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टाइप के डिसेंडेंट को खोजता है. यह खोज, दिए गए Range से शुरू होती है. |
find | Range | रेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. |
find | Range | यह फ़ंक्शन, दिए गए खोज नतीजे से शुरू करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. |
get | Object | यह एलिमेंट के एट्रिब्यूट वापस लाता है. |
get | String|null | बॉर्डर का रंग वापस लाता है. |
get | Number|null | यह बॉर्डर की चौड़ाई को पॉइंट में दिखाता है. |
get | Table | यह फ़ंक्शन, दी गई पंक्ति और सेल इंडेक्स पर मौजूद Table को वापस लाता है. |
get | Element | यह फ़ंक्शन, दिए गए चाइल्ड इंडेक्स पर मौजूद चाइल्ड एलिमेंट को वापस लाता है. |
get | Integer | यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स को वापस लाता है. |
get | Number|null | यह फ़ंक्शन, टेबल के किसी कॉलम की चौड़ाई को पॉइंट में दिखाता है. |
get | String|null | यह कुकी, लिंक का यूआरएल वापस पाती है. |
get | Element|null | यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है. |
get | Integer | यह कुकी, बच्चों की संख्या को वापस लाती है. |
get | Integer | Table की संख्या वापस लाता है. |
get | Container | यह एलिमेंट के पैरंट एलिमेंट को वापस लाता है. |
get | Element|null | यह एलिमेंट के पिछले समरूप एलिमेंट को वापस लाता है. |
get | Table | यह फ़ंक्शन, तय किए गए पंक्ति इंडेक्स पर मौजूद Table को वापस लाता है. |
get | String | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है. |
get | Text | टेक्स्ट अलाइनमेंट की जानकारी मिलती है. |
get | Element | यह एलिमेंट के Element को वापस लाता है. |
insert | Table | यह तय किए गए इंडेक्स पर, नया Table बनाता है और उसे डालता है. |
insert | Table | यह फ़ंक्शन, दिए गए इंडेक्स पर Table को जोड़ता है. |
is | Boolean | इससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं. |
remove | Table | यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट को हटाता है. |
remove | Table|null | इस तरीके का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है. |
remove | Table | यह फ़ंक्शन, तय किए गए पंक्ति इंडेक्स पर मौजूद Table को हटाता है. |
replace | Element | रेगुलर एक्सप्रेशन का इस्तेमाल करके, दिए गए टेक्स्ट पैटर्न की सभी जगहों पर, दिए गए रिप्लेसमेंट स्ट्रिंग को बदलता है. |
set | Table | यह एलिमेंट के एट्रिब्यूट सेट करता है. |
set | Table | बॉर्डर का रंग सेट करता है. |
set | Table | इससे बॉर्डर की चौड़ाई को पॉइंट में सेट किया जाता है. |
set | Table | यह विकल्प, तय किए गए कॉलम की चौड़ाई को पॉइंट में सेट करता है. |
set | Table | यह कुकी, लिंक किए गए यूआरएल को सेट करती है. |
set | Table | इससे टेक्स्ट अलाइनमेंट सेट किया जाता है. |
ज़्यादा जानकारी वाला दस्तावेज़
append Table Row()
यह एक नया Table बनाता है और उसे जोड़ता है.
वापसी का टिकट
Table — टेबल की नई लाइन वाला एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
append Table Row(tableRow)
यह दिए गए Table को जोड़ता है.
// 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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
table | Table | जोड़ी जाने वाली टेबल की लाइन. |
वापसी का टिकट
Table — यह जोड़े गए टेबल की लाइन का एलिमेंट है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
clear()
copy()
यह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है.
साथ ही, एलिमेंट में मौजूद सभी चाइल्ड एलिमेंट भी कॉपी किए जाते हैं. नए एलिमेंट का कोई पैरंट नहीं है.
वापसी का टिकट
Table — नई कॉपी.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
edit As Text()
बदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है.
रिच टेक्स्ट के तौर पर एलिमेंट के कॉन्टेंट में बदलाव करने के लिए, edit का इस्तेमाल करें. edit मोड में, टेक्स्ट के अलावा अन्य एलिमेंट (जैसे कि Inline और Horizontal) को अनदेखा कर दिया जाता है.
मिटाए गए टेक्स्ट रेंज में पूरी तरह से शामिल चाइल्ड एलिमेंट को एलिमेंट से हटा दिया जाता है.
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);
वापसी का टिकट
Text — मौजूदा एलिमेंट का टेक्स्ट वर्शन
find Element(elementType)
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में, तय किए गए टाइप के डिसेंडेंट को खोजता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
element | Element | खोजे जाने वाले एलिमेंट का टाइप. |
वापसी का टिकट
Range — खोज के नतीजे में, खोज के एलिमेंट की जगह के बारे में जानकारी देने वाला सर्च एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Element(elementType, from)
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टाइप के डिसेंडेंट को खोजता है. यह खोज, दिए गए Range से शुरू होती है.
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; } }
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
element | Element | खोजे जाने वाले एलिमेंट का टाइप. |
from | Range | वह खोज नतीजा जिससे खोज करनी है. |
वापसी का टिकट
Range — खोज के नतीजे में, खोज के एलिमेंट की अगली पोज़िशन के बारे में जानकारी देने वाला नतीजा.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern)
रेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
वापसी का टिकट
Range — खोज के नतीजे में खोजे गए टेक्स्ट की पोज़िशन दिखाता है. अगर कोई मैच नहीं मिलता है, तो यह शून्य होता है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern, from)
यह फ़ंक्शन, दिए गए खोज नतीजे से शुरू करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
from | Range | खोज के नतीजे में मौजूद वह आइटम जिससे खोज करनी है |
वापसी का टिकट
Range — खोज के नतीजे में, खोजे गए टेक्स्ट की अगली पोज़िशन दिखाता है. अगर कोई मैच नहीं मिलता है, तो यह शून्य होता है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes()
यह एलिमेंट के एट्रिब्यूट वापस लाता है.
नतीजा एक ऐसा ऑब्जेक्ट होता है जिसमें हर मान्य एलिमेंट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है. इसमें हर प्रॉपर्टी का नाम, Document इन्यूमरेशन में मौजूद किसी आइटम से मेल खाता है.
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]}`); }
वापसी का टिकट
Object — एलिमेंट के एट्रिब्यूट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Border Color()
बॉर्डर का रंग वापस लाता है.
// 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());
वापसी का टिकट
String|null — बॉर्डर का रंग, सीएसएस नोटेशन में फ़ॉर्मैट किया गया है. जैसे, '#ffffff'.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Border Width()
यह बॉर्डर की चौड़ाई को पॉइंट में दिखाता है.
// 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());
वापसी का टिकट
Number|null — बॉर्डर की चौड़ाई, पॉइंट में.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Cell(rowIndex, cellIndex)
यह फ़ंक्शन, तय की गई पंक्ति और सेल इंडेक्स पर मौजूद Table को वापस लाता है.
// 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());
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
row | Integer | उस पंक्ति का इंडेक्स जिसमें से सेल को वापस पाना है. |
cell | Integer | वह सेल इंडेक्स जिसे वापस पाना है. |
वापसी का टिकट
Table — टेबल सेल.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Child(childIndex)
यह फ़ंक्शन, दिए गए चाइल्ड इंडेक्स पर मौजूद चाइल्ड एलिमेंट को वापस लाता है.
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.'); }
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | जिस चाइल्ड एलिमेंट को वापस पाना है उसका इंडेक्स. |
वापसी का टिकट
Element — यह बताए गए इंडेक्स पर मौजूद चाइल्ड एलिमेंट होता है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Child Index(child)
यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स को वापस लाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Element | वह चाइल्ड एलिमेंट जिसका इंडेक्स वापस पाना है. |
वापसी का टिकट
Integer — बच्चे का इंडेक्स.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Column Width(columnIndex)
यह फ़ंक्शन, टेबल के किसी कॉलम की चौड़ाई को पॉइंट में दिखाता है.
// 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));
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
column | Integer | कॉलम इंडेक्स. |
वापसी का टिकट
Number|null — कॉलम की चौड़ाई, पॉइंट में.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url()
यह कुकी, लिंक का यूआरएल वापस पाती है.
वापसी का टिकट
String|null — लिंक यूआरएल या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो null
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Next Sibling()
यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है.
अगले सिबलिंग का पैरंट वही होता है जो मौजूदा एलिमेंट का होता है. साथ ही, यह मौजूदा एलिमेंट के बाद आता है.
वापसी का टिकट
Element|null — अगला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Num Children()
यह कुकी, बच्चों की संख्या को वापस लाती है.
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.`);
वापसी का टिकट
Integer — बच्चों की संख्या.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Num Rows()
Table की संख्या वापस लाता है.
// 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());
वापसी का टिकट
Integer — टेबल में पंक्तियों की संख्या.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Parent()
यह एलिमेंट के पैरंट एलिमेंट को वापस लाता है.
पैरंट एलिमेंट में मौजूदा एलिमेंट शामिल है.
वापसी का टिकट
Container — पैरंट एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Previous Sibling()
यह एलिमेंट के पिछले समरूप एलिमेंट को वापस लाता है.
पिछला सिबलिंग, मौजूदा एलिमेंट से पहले आता है और उसका पैरंट एलिमेंट भी मौजूदा एलिमेंट जैसा ही होता है.
वापसी का टिकट
Element|null — पिछला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Row(rowIndex)
यह फ़ंक्शन, तय किए गए पंक्ति इंडेक्स पर मौजूद Table को वापस लाता है.
// 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());
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
row | Integer | जिस पंक्ति को वापस पाना है उसका इंडेक्स. |
वापसी का टिकट
Table — टेबल की लाइन.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text()
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है.
वापसी का टिकट
String — एलिमेंट का कॉन्टेंट, टेक्स्ट स्ट्रिंग के तौर पर
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment()
टेक्स्ट अलाइनमेंट की जानकारी मिलती है. अलाइनमेंट के लिए ये विकल्प उपलब्ध हैं: Document, Document, और Document.
वापसी का टिकट
Text — टेक्स्ट अलाइनमेंट का टाइप या null अगर टेक्स्ट में कई तरह के टेक्स्ट अलाइनमेंट शामिल हैं या टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Type()
यह एलिमेंट के Element को वापस लाता है.
किसी एलिमेंट के टाइप का पता लगाने के लिए, get का इस्तेमाल करें.
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.'); }
वापसी का टिकट
Element — एलिमेंट का टाइप.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Table Row(childIndex)
यह तय किए गए इंडेक्स पर, नया Table बनाता है और उसे डालता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को जोड़ना है |
वापसी का टिकट
Table — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Table Row(childIndex, tableRow)
यह फ़ंक्शन, दिए गए इंडेक्स पर Table को जोड़ता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को जोड़ना है |
table | Table | टेबल में जोड़ने के लिए पंक्ति |
वापसी का टिकट
Table — टेबल में जोड़ी गई लाइन का एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is At Document End()
इससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं.
वापसी का टिकट
Boolean — इससे पता चलता है कि एलिमेंट टैब के आखिर में है या नहीं.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Child(child)
यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट को हटाता है.
// 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());
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Element | हटाया जाने वाला चाइल्ड एलिमेंट. |
वापसी का टिकट
Table — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove From Parent()
इस तरीके का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है.
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(); }
वापसी का टिकट
Table|null — हटाया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove Row(rowIndex)
यह फ़ंक्शन, तय किए गए पंक्ति इंडेक्स पर मौजूद Table को हटाता है.
// 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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
row | Integer | हटाने के लिए लाइन का इंडेक्स. |
वापसी का टिकट
Table — हटाई गई लाइन.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
replace Text(searchPattern, replacement)
रेगुलर एक्सप्रेशन का इस्तेमाल करके, दिए गए टेक्स्ट पैटर्न की सभी जगहों पर, दिए गए रिप्लेसमेंट स्ट्रिंग को बदलता है.
खोज के पैटर्न को स्ट्रिंग के तौर पर पास किया जाता है, न कि JavaScript रेगुलर एक्सप्रेशन ऑब्जेक्ट के तौर पर. इस वजह से, आपको पैटर्न में मौजूद सभी बैकस्लैश को एस्केप करना होगा.
यह तरीका, Google की RE2 रेगुलर एक्सप्रेशन लाइब्रेरी का इस्तेमाल करता है. इससे सपोर्ट किए गए सिंटैक्स सीमित हो जाते हैं.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText('^.*Apps ?Script.*$', 'Apps Script');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोज के लिए रेगुलर एक्सप्रेशन पैटर्न |
replacement | String | वह टेक्स्ट जिसका इस्तेमाल, बदले गए टेक्स्ट के तौर पर करना है |
वापसी का टिकट
Element — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Attributes(attributes)
यह एलिमेंट के एट्रिब्यूट सेट करता है.
तय किया गया एट्रिब्यूट पैरामीटर एक ऑब्जेक्ट होना चाहिए. इसमें हर प्रॉपर्टी का नाम, Document इन्यूमरेशन में मौजूद एक आइटम होता है. साथ ही, हर प्रॉपर्टी की वैल्यू, लागू की जाने वाली नई वैल्यू होती है.
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
attributes | Object | एलिमेंट के एट्रिब्यूट. |
वापसी का टिकट
Table — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Border Color(color)
बॉर्डर का रंग सेट करता है.
// 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');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
color | String | बॉर्डर का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया. |
वापसी का टिकट
Table — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Border Width(width)
इससे बॉर्डर की चौड़ाई को पॉइंट में सेट किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
width | Number | बॉर्डर की चौड़ाई, पॉइंट में |
वापसी का टिकट
Table — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Column Width(columnIndex, width)
यह विकल्प, तय किए गए कॉलम की चौड़ाई को पॉइंट में सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
column | Integer | कॉलम इंडेक्स |
width | Number | बॉर्डर की चौड़ाई, पॉइंट में |
वापसी का टिकट
Table — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Link Url(url)
यह कुकी, लिंक किए गए यूआरएल को सेट करती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
url | String | लिंक का यूआरएल |
वापसी का टिकट
Table — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text Alignment(textAlignment)
इससे टेक्स्ट अलाइनमेंट सेट किया जाता है. अलाइनमेंट के लिए ये विकल्प उपलब्ध हैं: Document, Document, और Document.
// 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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | Text | टेक्स्ट अलाइनमेंट का वह टाइप जिसे लागू करना है |
वापसी का टिकट
Table — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents