# range.setRichTextValue()

{% tabs %}
{% tab title="💾 程式" %}
```javascript
// 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);
```

![](https://2527454625-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MfvEFZnSBhKT6fJmus0%2Fuploads%2FKEE6u0VXZe7b5jDHfu14%2Frich%20text.png?alt=media\&token=acb5ec88-2e51-48d4-af02-e2e7c1461a85)
{% endtab %}

{% tab title="🗣 討論" %}
* [Bold specific text in Google Sheets](https://stackoverflow.com/a/69750237/5409815)
{% endtab %}

{% tab title="📘 手冊" %}
* [Range](https://developers.google.com/apps-script/reference/spreadsheet/range) ⟩&#x20;
  * .[setRichTextValue()](https://developers.google.com/apps-script/reference/spreadsheet/range#setrichtextvaluevalue)
* [SpreadsheetApp](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app) ⟩&#x20;
  * [.newRichTextValue()](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#newrichtextvalue) - returns [RichTextValueBuilder](https://developers.google.com/apps-script/reference/spreadsheet/rich-text-value-builder).
  * [.newTextStyle()](https://developers.google.com/apps-script/reference/spreadsheet/spreadsheet-app#newtextstyle) - returns [TextStyleBuilder](https://developers.google.com/apps-script/reference/spreadsheet/text-style-builder).
* [TextStyleBuilder](https://developers.google.com/apps-script/reference/spreadsheet/text-style-builder)
* [RichTextValueBuilder](https://developers.google.com/apps-script/reference/spreadsheet/rich-text-value-builder)
{% endtab %}

{% tab title="👥 相關" %}
* [richtextvaluebuilder](../richtextvaluebuilder "mention")
{% endtab %}
{% endtabs %}
