Stay organized with collections Save and categorize content based on your preferences.
RichTextValueBuilderA builder for Rich Text values.
Detailed documentationbuild()
Creates a Rich Text value from this builder.
ReturnRichTextValue
— A Rich Text value created from this builder.
setLinkUrl(startOffset, endOffset, linkUrl)
Sets the link URL for the given substring of this value, or clears it if linkUrl
is null
.
// Creates a Rich Text value for the text "foo no baz" with "foo" pointing to // "https://bar.foo" and "baz" to "https://abc.xyz". // "foo" is underlined with the default link color, whereas "baz" has its text // style overridden by a call to `setTextStyle`, and is therefore black and bold // with no underlining. const boldStyle = SpreadsheetApp.newTextStyle() .setUnderline(false) .setBold(true) .setForegroundColor('#000000') .build(); const value = SpreadsheetApp.newRichTextValue() .setText('foo no baz') .setLinkUrl(0, 3, 'https://bar.foo') .setLinkUrl(7, 10, 'https://abc.xyz') .setTextStyle(7, 10, boldStyle) .build();Parameters Name Type Description
startOffset
Integer
The start offset for the substring, inclusive. endOffset
Integer
The end offset for the substring, exclusive. linkUrl
String
The link URL being set. Return
RichTextValueBuilder
— This builder, for chaining.
setLinkUrl(linkUrl)
Sets the link URL for the entire value, or clears it if linkUrl
is null
.
// Creates a Rich Text value for the text "Foo" which points to // "https://bar.foo". const value = SpreadsheetApp.newRichTextValue() .setText('Foo') .setLinkUrl('https://bar.foo') .build();Parameters Name Type Description
linkUrl
String
The link URL being set. Return
RichTextValueBuilder
— This builder, for chaining.
setTextStyle(startOffset, endOffset, textStyle)
Applies a text style to the given substring of this value. Offsets are 0 based and are relative to the cell's text value. Does nothing if textStyle
is null
.
// Creates a Rich Text value for the text "HelloWorld", with "Hello" bolded, and // "World" italicized. const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const italic = SpreadsheetApp.newTextStyle().setItalic(true).build(); const value = SpreadsheetApp.newRichTextValue() .setText('HelloWorld') .setTextStyle(0, 5, bold) .setTextStyle(5, 10, italic) .build();Parameters Name Type Description
startOffset
Integer
The start offset for the substring, inclusive. endOffset
Integer
The end offset for the substring, exclusive. textStyle
TextStyle
The text style being set. Return
RichTextValueBuilder
— This builder, for chaining.
setTextStyle(textStyle)
Applies a text style to the entire value. Previously set text styles are only affected if they are directly overwritten by values within textStyle
. Does nothing if textStyle
is null
.
// Creates a Rich Text value for the text "HelloWorld" with "Hello" bolded and // italicized, and "World" only italicized. const bold = SpreadsheetApp.newTextStyle().setBold(true).build(); const italic = SpreadsheetApp.newTextStyle().setItalic(true).build(); const value = SpreadsheetApp.newRichTextValue() .setText('HelloWorld') .setTextStyle(0, 5, bold) .setTextStyle(italic) .build();Parameters Name Type Description
textStyle
TextStyle
The text style being set. Return
RichTextValueBuilder
— This builder, for chaining.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["The `RichTextValueBuilder` enables the creation and customization of rich text values within a spreadsheet."],["You can set text styles, like bold or italic, for specific portions or the entire text value using the builder."],["Hyperlinks can be added to substrings or the whole text value via the `setLinkUrl` methods of the builder."],["The builder provides a fluent interface using a chaining pattern, allowing for sequential method calls to construct the desired rich text."],["Finally, call the `build()` method to generate the `RichTextValue` object based on the configurations set in the builder."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4