'Empty row above appended element

I wanted to insert a new table at the top of a Google docs page, and then a piece of text, I did the following:

function myFunction() {
var doc = DocumentApp.create("Random mix");
body=doc.getBody();
var cell = [
['Q11','Q21'],
['Q12','Q22']
];
body.insertTable(0,cell);
body.appendParagraph('my paragraphs..');
}

However, the table is only on the second row (there is still a blank line above the table). And there is always a blank line between the table and the text. How can the top of the table and the middle of the table with the text have no blank rows (they are close together)? Thank you for your help!



Solution 1:[1]

This is the best I could do

function myFunction() {
  var doc = DocumentApp.create("Random mix");
  body = doc.getBody();
  var cell = [
    ['Q11', 'Q21'],
    ['Q12', 'Q22']
  ];
  body.insertTable(0, cell);
  body.appendParagraph('my paragraphs..');
  body.removeChild(body.getChild(1));
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Cooper