阅读图形标题 [英] Reading title of Graph
问题描述
使用Google脚本,是否可以在Google电子表格中读取图表的标题?
Using Google Script, is it possible to read the title of a graph in google spreadsheets?
我喜欢做的是从Google Spreadsheet到特定位置的Google文档中。
What I like to do is to place a specific graph from Google Spreadsheet into a Google Document in a specific location.
到目前为止,我可以将Google电子表格中的图形放置在预先指定位置的Google文档中。但是,我还没有控制哪个图来自哪里。
So far I can place a graph from Google Spreadsheet into a Google Document in a prespecified location. However, I do not yet control which graph comes where.
function test() {
SpreadsheetApp.flush();
var Grafieken = SpreadsheetApp.getActiveSheet().getCharts();
var targetDoc = DocumentApp.openById(DOC_id);
var DBody = targetDoc.getBody();
var Grafiek;
for (var i in Grafieken)
Grafiek = Grafieken[i];
var locatie = DBody.findText('%Grafiek'+i+'%').getElement().getParent().asParagraph().appendInlineImage(Grafiek);
}
}
脚本为我工作,我需要知道哪个图是哪个。我想,这将是最简单的方法来维护使用图表标题。任何建议?
For the script to work for me, I need to know which graph is which. I thought, that would be the easiest way to maintain to use the Graph Title for this. Any suggestions?
推荐答案
要获得图表标题,请使用getOptions()。get('title')。
To get the chart title use the call getOptions().get('title').
检查下面的代码:
Check the code bellow
function test() {
SpreadsheetApp.flush();
var Grafieken = SpreadsheetApp.getActiveSheet().getCharts();
var targetDoc = DocumentApp.openById(DOC_id);
var DBody = targetDoc.getBody();
var Grafiek;
for (var i in Grafieken)
Grafiek = Grafieken[i];
// Get chart title
var charTitle = Grafiek.getOptions().get("title");
var locatie = DBody.findText('%'+charTitle+'%').getElement().getParent().asParagraph().appendInlineImage(Grafiek);
}
这篇关于阅读图形标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!