Reputation: 397
Trying to insert text to a Google Doc. I would like it to be formated as followed:
Text1
Space
Text2
Space
I have the following code:
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!');
}
The results from running this, gives us text-in-text and just a mess.
Upvotes: 0
Views: 2440
Reputation: 397
Use appendText instead of insertText, like this:
text.appendText('This is ju for test, lorem ipsum!\n');
And add "\n" to add a 'new row'
Upvotes: 1