Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.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
Javascript 将Google工作表图表导出到Google文档问题_Javascript_Google Apps Script_Google Sheets_Google Visualization_Google Docs - Fatal编程技术网

Javascript 将Google工作表图表导出到Google文档问题

Javascript 将Google工作表图表导出到Google文档问题,javascript,google-apps-script,google-sheets,google-visualization,google-docs,Javascript,Google Apps Script,Google Sheets,Google Visualization,Google Docs,我正在将一张图表从谷歌工作表导出到谷歌文档。但不知何故,原始的谷歌图表并没有导出到谷歌文档。它的颜色和大小不同,谷歌文档中也缺少一些图表数据。我还想在谷歌文档中调整导出图表的大小。以下是脚本: function open() { var sh = SpreadsheetApp.getActiveSheet(); var doc = DocumentApp.openById('1x41183-Fhn3BRPi3CFzEhB9vStGqXCgt00Z7fuZiq3s'); va

我正在将一张图表从谷歌工作表导出到谷歌文档。但不知何故,原始的谷歌图表并没有导出到谷歌文档。它的颜色和大小不同,谷歌文档中也缺少一些图表数据。我还想在谷歌文档中调整导出图表的大小。以下是脚本:

    function open() {

  var sh = SpreadsheetApp.getActiveSheet();
  var doc = DocumentApp.openById('1x41183-Fhn3BRPi3CFzEhB9vStGqXCgt00Z7fuZiq3s');
  var body = doc.getBody();
  

  var search = body.findText("Graph_Here");
  
  if(search!= null)
  {
  var element = search.getElement();
  var parent = element.getParent();
  var paragraph = parent.asParagraph();
    
  var chart = SpreadsheetApp.getActiveSheet().getCharts()[0]; //Get First Chart of Google Sheet

  paragraph.insertInlineImage(1, chart).getAs("image/png");  // Place the Chart into the Google Doc 
  paragraph.getChild(2).removeFromParent();                 // Remove the previous chart 
    
  }
  
  else 
  {
     Logger.log("No place Holder");
  }
} 




如果您有任何建议,我们将不胜感激。

我想这篇文章的答案可能就是您问题的答案。是的,我在那里找到了解决办法。非常感谢。