range.setRichTextValue()

// custom style: black, bold, without underline
const boldNoUnderline = SpreadsheetApp.newTextStyle()
  .setUnderline(false)            // no underline
  .setBold(true)                  // bold
  .setForegroundColor("#000000")  // black
  .build();

// RichTextValueBuilder
const richText = SpreadsheetApp.newRichTextValue()
  .setText("foo no baz")                  // plain text
  .setLinkUrl(0, 3, "https://bar.foo")    // "foo" pointing to "https://bar.foo"
  .setLinkUrl(7, 10, "https://abc.xyz")   // "baz" pointing to "https://abc.xyz"
  .setTextStyle(7, 10, boldNoUnderline)   // "baz" black, bold, without underline
  .build();

let sheet = app.sheet.byName('temp');     // custom method
let range = sheet.getRange('A1');
range.setRichTextValue(richText);

Last updated