How to use CSS styling WITHIN google sheets

36 views
Skip to first unread message

Wilfred R

unread,
Mar 17, 2017, 9:05:47 AM3/17/17
to Google Visualization API
Ultimate goal: Have a linked table that with nice layout in google docs (slide) from data in google sheets.

Obvious way for linking functionality: Insert a TableChart from google sheets into google docs.

Problem: Layout is horrible and in google sheets chart editor no possibilities to do something about it.

After some digging I found that:
Embedded chart builder accepts options

An option op TableChart option is to give CSSClassnames to header rows etc.

What I have so far:

function newChart() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];

 var chart = sheet.newChart()
     .setChartType(Charts.ChartType.TABLE)
     .addRange(sheet.getRange("A1:C8"))
     .setPosition(5, 5, 0, 0)
     .setOption('allowHtml', true)
     .setOption('height', 500)
     .setOption('cssClassNames', {headerRow: 'HeaderRow'})
     .build();

 sheet.insertChart(chart);
}

Million dollar questions. How can I set the CSS ClassNames in my app code so that it is taken into account when building the chart??

Or am I trying to do the impossible. Are there other, simpler ways.

Thanks
Reply all
Reply to author
Forward
0 new messages