📜  使用谷歌脚本用表格替换文本 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:31.432000             🧑  作者: Mango

代码示例1
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)
}