Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 使用Google Appscript在文档中选择特定表_Google Apps Script_Google Docs - Fatal编程技术网

Google apps script 使用Google Appscript在文档中选择特定表

Google apps script 使用Google Appscript在文档中选择特定表,google-apps-script,google-docs,Google Apps Script,Google Docs,我有一个谷歌文档,其中包含一些文本、图像和表格。我需要使用Appscript获得一个特定的表来编辑(追加行)。我怎么做? 非常感谢。像这样的吗 函数appendtable(){ var body=DocumentApp.getActiveDocument().getBody(), searchElement=body.findElement(DocumentApp.ElementType.TABLE), element=searchElement.getElement(), table=ele

我有一个谷歌文档,其中包含一些文本、图像和表格。我需要使用Appscript获得一个特定的表来编辑(追加行)。我怎么做? 非常感谢。

像这样的吗

函数appendtable(){
var body=DocumentApp.getActiveDocument().getBody(),
searchElement=body.findElement(DocumentApp.ElementType.TABLE),
element=searchElement.getElement(),
table=element.asTable();
table.appendTableRow().appendTableCell();
}
更新: 我做了以下变通:

 var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var range = body.findText("#PLACEHOLDER#");
  var table = body.findElement(DocumentApp.ElementType.TABLE, range);
在文档中表格的前面添加#占位符#文本,以后可以删除