[英]Insert text at specific position in Google Docs
試圖將文本插入Google文檔。 我希望其格式如下:
文字1
空間
文字2
空間
我有以下代碼:
function InsertText1() {
var body = DocumentApp.getActiveDocument().getBody();
var text = body.editAsText();
text.insertText(1, 'This is ju for test, lorem ipsum!');
}
function InsertText2(){
var body = DocumentApp.getActiveDocument().getBody();
var text = body.editAsText();
text.insertText(10, 'What test?, lorem ipsum!');
}
使用appendText而不是insertText,如下所示:
text.appendText('This is ju for test, lorem ipsum!\n');
並添加“ \\ n”以添加“新行”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.