You need to use .getValue() in order to set cell equal to the contents of A1's.
Try this:
var cell = range.getCell(1,1).getValue();
Question
I have a chart in Google spreadsheets. The content changes when selecting a menu, with drop down menu. Everything works, except I can't get the chart name to be flexible too.
I want the chart name to be cell A1.
What is wrong with my code?
}
function expandCharts() {
var sheet = SpreadsheetApp.getActiveSheet()
// Get a list of all charts on this Sheet.
var charts = sheet.getCharts();
for (var i in charts) {
var range = sheet.getRange("A1:D4");
var chart = charts[i];
var cell = range.getCell(1,1);
var ranges = chart.getRanges();
// Returns an EmbeddedChartBuilder with this chart’s settings.
var builder = chart.modify();
for (var j in ranges) {
var range = ranges[j];
}
// Update title.
builder.setOption('title', 'Netliq ' + cell)
// Must be called to save changes.
sheet.updateChart(builder.build());
} }
La solution
You need to use .getValue() in order to set cell equal to the contents of A1's.
Try this:
var cell = range.getCell(1,1).getValue();