【发布时间】:2017-10-12 04:15:47
【问题描述】:
我有一个脚本,它应该使用 Google 表格中的各种值填充 Google 文档正文中的一系列占位符。我希望合并到模板中的对象之一是 EmbeddedChartBuilder 对象:
var chart = sheet.newChart()
.addRange(range)
.setChartType(Charts.ChartType.BAR)
.setPosition(i, 6, 0, 0)
.setOption('legend.position', 'none')
.setOption('height', 50)
.setOption('width', 700)
.setOption('colors', ['black', 'white'])
.setOption('hAxis.minValue', 0)
.setOption('hAxis.maxValue', 10)
.setOption('backgroundColor.fill', 'white')
.setOption('hAxis.gridlines.color', 'white')
.setOption('hAxis.gridlines.count', 0);
sheet.insertChart(chart.build());
合并代码如下:
body.replaceText('{name}', company.name);
body.replaceText('{score}', company.score);
body.replaceText('{applyTime}', company.applyTime);
body.replaceText('{confEmail}', company.confEmail);
body.replaceText('{mobiFriendly}', company.mobiFriendly);
body.replaceText('{chart}', chart);
最后一行 body.replaceText('{chart}', chart); 当然只是简单地将 Doc 中的占位符替换为“EmbeddedChartBuilder”。
有没有办法将图表作为图像或其他东西插入占位符?如果有,怎么做?
【问题讨论】:
标签: javascript google-apps-script google-sheets google-docs