Home > database >  Empty row above appended element
Empty row above appended element

Time:04-13

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!

CodePudding user response:

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));
}
  • Related