में findtext की बाल अनुक्रमणिका प्राप्त करें मेरा लक्ष्य किसी अन्य दस्तावेज़ की सामग्री के साथ Google ड्राइव दस्तावेज़ में पाठ के एक टुकड़े को प्रतिस्थापित करना है।google API स्क्रिप्ट
मैं दस्तावेज़ को अन्य दस्तावेज़ में एक निश्चित स्थिति में सम्मिलित करने में सक्षम हूं, लेकिन मुझे उस पाठ के टुकड़े के बच्चे सूचकांक को निर्धारित करने में समस्या हो रही है जिसे मैं प्रतिस्थापित करना चाहता हूं। यहां मेरे पास अब तक है:
function replace(docId, requirementsId) {
var body = DocumentApp.openById(docId).getActiveSection();
var searchResult = body.findText("<<requirementsBody>>");
var pos = searchResult.?? // Here I would need to determine the position of the searchResult, to use it in the insertParagraph function below
var otherBody = DocumentApp.openById(requirementsId).getActiveSection();
var totalElements = otherBody.getNumChildren();
for(var j = 0; j < totalElements; ++j) {
var element = otherBody.getChild(j).copy();
var type = element.getType();
if(type == DocumentApp.ElementType.PARAGRAPH) {
body.insertParagraph(pos,element);
} else if(type == DocumentApp.ElementType.TABLE) {
body.insertTable(pos,element);
} else if(type == DocumentApp.ElementType.LIST_ITEM) {
body.insertListItem(pos,element);
} else {
throw new Error("According to the doc this type couldn't appear in the body: "+type);
}
}
};
किसी भी सहायता की सराहना की जाएगी।
जब एक इनलाइन छवि findText स्थान से पहले वहाँ है, यह आवश्यक तरह छवि से पहले पैराग्राफ के बच्चे सूचकांक देता है, छवि के बाद नहीं। क्या आसपास कोई काम है? –