如何在保持格式化的同时复制文件?

时间:2016-01-29 12:22:07

标签: google-apps-script

只是为了澄清这是Google Active Script。

阅读Google文档文件(这是一个带有占位符和格式的模板(标注,标签,下划线等)占位符为{placeholderName}我使用Body.replaceText('{placeholderName}', placeholderName)这样可以正常工作。插入的数据是包含在Google电子表格中(也可以正常工作)我只是试图在修改后的模板文件中保留格式,然后将其附加到最终文件中。

 var SerialLetterID = DriveApp.getFileById('google_doc_id').makeCopy('filename').getId(); 

var fBody = DocumentApp.openById(SerialLetterID);

 // an independent copy of the template ( with formatting )
var Template = fBody.getBody().copy(); 

数据替换占位符后

// insert a pageBreak
fBody.getBody().appendPageBreak();

/* 
 this is where I'm getting the issues.. everything works but the getText()
 removes all formatting.  I looked for a getCopy() or something of the like
 but nothing like that seems to exist.  So, in OOP google style how would I     
 copy the page, maintain formatting in the same manner as getText() works?
*/
// add template with placeholders 
fBody.getBody().appendParagraph(Template.getText());

我希望我解释了我想要做的事情。

0 个答案:

没有答案