The following example will create a table from the newly introduced chartTable (without dashboard)
function doGet(e)
// create application
var app = UiApp.createApplication();
// set arrays for table
var headerRange = s00.getRange(1, 1, 1, s00.getLastColumn()).getValues()[0];
var formatRange = s00.getRange(2, 1, 1, s00.getLastColumn()).getValues()[0];
var dataRange = s00.getRange(3, 1, s00.getLastRow()-2, s00.getLastColumn()).getValues();
// create holder for table data
var data = Charts.newDataTable();
// prepare the columns
for(var i=0;
i<headerRange.length; i++) {
// set format instance
var format = formatRange[i];
// add column with format and header
data.addColumn(Charts.ColumnType[format], headerRange[i]);
}
// add rows
for(var j=0,
lk=dataRange.length; j<lk; j++) {
// set array at once
data.addRow(dataRange[j]);
}
// build holder
data.build();
// create table and set data
var tableChart = Charts.newTableChart().setDimensions(700, 500).setDataTable(data).build();
// add table to application
app.add(tableChart);
// return to application
return app;
}
And here's the result |
Remarks |
- Open spreadsheet, to see the different ranges (header, format and data):
spreadsheet for table chart - Please pay attention to both the for loops:
http://www.openjs.com/articles/for_loop.php