2
votes

I have a Google Document that contains some text, images, and tables. I need to get one specific table to edit (Append Rows) using Appscript. How can I do it? Thanks a lot.

2

2 Answers

1
votes

Something like this?

function appendtable() {
 var body = DocumentApp.getActiveDocument().getBody(),
      searchElement = body.findElement(DocumentApp.ElementType.TABLE),
      element = searchElement.getElement(),
      table = element.asTable();
      table.appendTableRow().appendTableCell();

}
0
votes

UPDATE : I made this workaround :

 var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var range = body.findText("#PLACEHOLDER#");
  var table = body.findElement(DocumentApp.ElementType.TABLE, range);

Add #PLACEHOLDER# Text just before the table in the document, it can be deleted later.