Answers for "Replacing text with table using google script"

0

Replacing text with table using google script

function searchTextReplTable(texttofind){
  var doc=DocumentApp.getActiveDocument();
  var body=doc.getBody();
  var rgel=body.findText(texttofind);
  var element=rgel.getElement();
  var childIndex=body.getChildIndex(element.getParent());
  var t=[];//This is the table I used
  for(var i=0;i<5;i++){//just created a 5,5 table with row, col indices
    t[i]=[];
    for(var j=0;j<5;j++){
      t[i][j]=Utilities.formatString('%s,%s',i,j);
    }
  }
  body.getChild(childIndex).asText().setText('');
  body.insertTable(childIndex,t)
}
Posted by: Guest on July-24-2021

Code answers related to "Replacing text with table using google script"

Browse Popular Code Answers by Language