Class RichTextValue Stay organized with collections Save and categorize content based on your preferences.
Page Summary
RichTextValue represents cell text with substrings that can have different text styles.
A "run" is the longest unbroken substring with the same text style.
The RichTextValue class provides methods to access text content, styling, link URLs, and indices within a cell.
You can retrieve the text style or link URL for the entire value or a specific range using offset parameters.
The
getRuns()method splits the Rich Text string into an array of runs based on consistent text styles.
A stylized text string used to represent cell text. Substrings of the text can have differenttext styles.
Arun is the longest unbroken substring having the same text style. For example, thesentence, "Thischildis carryingapples" has 4 runs:['This ', 'child ','is carrying ', 'apples'].
Methods
| Method | Return type | Brief description |
|---|---|---|
copy() | Rich | Returns a builder for a Rich Text value initialized with the values of this Rich Text value. |
get | Integer | Gets the end index of this value in the cell. |
get | String|null | Returns the link URL for this value. |
get | String|null | Returns the link URL for the text fromstart toend. |
get | Rich | Returns the Rich Text string split into an array of runs, wherein each run is the longestpossible substring having a consistent text style. |
get | Integer | Gets the start index of this value in the cell. |
get | String | Returns the text of this value. |
get | Text | Returns the text style of this value. |
get | Text | Returns the text style of the text fromstart toend. |
Detailed documentation
copy()
Returns a builder for a Rich Text value initialized with the values of this Rich Text value.
Return
Rich — A builder for a Rich Text value.
getEndIndex()
Gets the end index of this value in the cell.
Return
Integer — The end index of this value in the cell.
getLinkUrl()
Returns the link URL for this value.
Return
String|null — The link URL for this value, ornull if there is no link or if there are multiple different links.
getLinkUrl(startOffset, endOffset)
Returns the link URL for the text fromstart toend. Offsets are 0based and relative to the cell's text, with the start offset being inclusive and the end offsetbeing exclusive.
Parameters
| Name | Type | Description |
|---|---|---|
start | Integer | The start offset. |
end | Integer | The end offset. |
Return
String|null — The link URL for this value, ornull if there is no link or if multiple different links are in the given range.
getRuns()
Returns the Rich Text string split into an array of runs, wherein each run is the longestpossible substring having a consistent text style.
Return
Rich — An array of runs.
getStartIndex()
Gets the start index of this value in the cell.
Return
Integer — The start index of this value in the cell.
getText()
Returns the text of this value.
Return
String — The text of this value.
getTextStyle()
getTextStyle(startOffset, endOffset)
Returns the text style of the text fromstart toend. Offsets are 0based and relative to the cell's text, with the start offset being inclusive and the end offsetbeing exclusive.
Parameters
| Name | Type | Description |
|---|---|---|
start | Integer | The start offset. |
end | Integer | The end offset. |
Return
Text — The text style of the given substring of this value.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.