Stretch
Stretch

Reputation: 71

setting alternating values to be bold

I am trying to manipulate some data from a google spreadsheet into a google doc. I am using the code below to pull a cell range and then put the results into my doc.

var sh11 = sh0.getRange('P2:P10').getValues();
var announcement3 = ""; for (var i = 0; i <= sh11.length - 1; i++) { announcement3 += sh11[i]+"\n"; }

Is there a way to set the results from every other cell to be bold? I tried the straight forward way of setting the cells themselves to be bold but that didn't work. I also tried to define it by using

textelement.setBold

But that didn't work either. I had a look at https://developers.google.com/apps-script/reference/spreadsheet/range?csw=1#setFontWeight(String) but I think I am missing something. Any help would be greatly appreciated.

Thank you,

Paul

Upvotes: 0

Views: 1287

Answers (1)

Rafael De Alemar Vidal
Rafael De Alemar Vidal

Reputation: 173

If you trying to set text bold of a spreadsheet cell, then you have to use 'setFontWeight("bold")'. Ex.:

SpreadsheetApp.getActiveSheet().getRange("A1").setFontWeight("bold");

If you trying to set text bold of a document, then you have to use 'setBold(true)'. Ex.:

var doc = DocumentApp.getActiveDocument().getBody().editAsText(); doc.appendText("text to insert").setBold(true);

Upvotes: 1

Related Questions