Class RichTextValue
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Giá trịVăn bảnđa dạng thức
Chuỗi văn bản được tạo kiểu dùng để biểu thị văn bản trong ô. Các chuỗi con của văn bản có thể có nhiều kiểu văn bản.
Chuỗi văn bản là chuỗi con không bị gián đoạn dài nhất có cùng kiểu văn bản. Ví dụ: câu "Đứa trẻ này đang mang táo" có 4 lần chạy: ['This ', 'child ',
'is carrying ', 'apples']
.
Tài liệu chi tiết
copy()
Trả về một trình tạo cho giá trị Văn bản đa dạng thức được khởi tạo bằng các giá trị của giá trị Văn bản đa dạng thức này.
Cầu thủ trả bóng
RichTextValueBuilder
– Trình tạo cho giá trị Văn bản đa dạng thức.
getEndIndex()
Lấy chỉ mục cuối của giá trị này trong ô.
Cầu thủ trả bóng
Integer
– Chỉ mục kết thúc của giá trị này trong ô.
getLinkUrl()
Trả về URL đường liên kết cho giá trị này.
Cầu thủ trả bóng
String
– URL liên kết cho giá trị này hoặc null
nếu không có đường liên kết hoặc nếu có nhiều đường liên kết khác nhau.
getLinkUrl(startOffset, endOffset)
Trả về URL liên kết cho văn bản từ startOffset
đến endOffset
. Độ lệch dựa trên 0 và tương ứng với văn bản của ô, trong đó độ lệch bắt đầu bao gồm và độ lệch kết thúc không bao gồm.
Tham số
Tên | Loại | Mô tả |
startOffset | Integer | Độ lệch bắt đầu. |
endOffset | Integer | Độ lệch kết thúc. |
Cầu thủ trả bóng
String
– URL liên kết cho giá trị này hoặc null
nếu không có đường liên kết hoặc nếu có nhiều đường liên kết khác nhau trong phạm vi đã cho.
getRuns()
Trả về chuỗi Văn bản đa dạng thức được chia thành một mảng các lần chạy, trong đó mỗi lần chạy là một chuỗi con dài nhất có thể có kiểu văn bản nhất quán.
Cầu thủ trả bóng
RichTextValue[]
– Một mảng các lần chạy.
getStartIndex()
Lấy chỉ mục bắt đầu của giá trị này trong ô.
Cầu thủ trả bóng
Integer
– Chỉ mục bắt đầu của giá trị này trong ô.
getText()
Trả về văn bản của giá trị này.
Cầu thủ trả bóng
String
– Văn bản của giá trị này.
getTextStyle()
Trả về kiểu văn bản của giá trị này.
Cầu thủ trả bóng
TextStyle
– Kiểu văn bản của giá trị này.
getTextStyle(startOffset, endOffset)
Trả về kiểu văn bản của văn bản từ startOffset
thành endOffset
. Độ lệch dựa trên 0 và tương ứng với văn bản của ô, trong đó độ lệch bắt đầu bao gồm và độ lệch kết thúc không bao gồm.
Tham số
Tên | Loại | Mô tả |
startOffset | Integer | Độ lệch bắt đầu. |
endOffset | Integer | Độ lệch kết thúc. |
Cầu thủ trả bóng
TextStyle
– Kiểu văn bản của chuỗi con nhất định của giá trị này.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003eRichTextValue\u003c/code\u003e objects represent stylized text within a spreadsheet cell, allowing substrings to have varied styles.\u003c/p\u003e\n"],["\u003cp\u003eText is broken into "runs," which are the longest continuous substrings sharing the same style.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eRichTextValue\u003c/code\u003e class provides methods to access and manipulate text, styles, and links within these runs.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can retrieve individual runs, get/set text styles, and extract link URLs using dedicated methods.\u003c/p\u003e\n"],["\u003cp\u003eMethods like \u003ccode\u003ecopy()\u003c/code\u003e, \u003ccode\u003egetText()\u003c/code\u003e, \u003ccode\u003egetRuns()\u003c/code\u003e, and \u003ccode\u003egetTextStyle()\u003c/code\u003e offer manipulation of \u003ccode\u003eRichTextValues\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class RichTextValue\n\nRichTextValue\n\nA stylized text string used to represent cell text. Substrings of the text can have different\ntext styles.\n\nA *run* is the longest unbroken substring having the same text style. For example, the\nsentence, \"This **child** *is carrying* apples\" has 4 runs: `['This ', 'child ',\n'is carrying ', 'apples']`. \n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------------|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| [copy()](#copy()) | [RichTextValueBuilder](/apps-script/reference/spreadsheet/rich-text-value-builder) | Returns a builder for a Rich Text value initialized with the values of this Rich Text value. |\n| [getEndIndex()](#getEndIndex()) | `Integer` | Gets the end index of this value in the cell. |\n| [getLinkUrl()](#getLinkUrl()) | `String` | Returns the link URL for this value. |\n| [getLinkUrl(startOffset, endOffset)](#getLinkUrl(Integer,Integer)) | `String` | Returns the link URL for the text from `start``Offset` to `end``Offset`. |\n| [getRuns()](#getRuns()) | [RichTextValue[]](#) | Returns the Rich Text string split into an array of runs, wherein each run is the longest possible substring having a consistent text style. |\n| [getStartIndex()](#getStartIndex()) | `Integer` | Gets the start index of this value in the cell. |\n| [getText()](#getText()) | `String` | Returns the text of this value. |\n| [getTextStyle()](#getTextStyle()) | [TextStyle](/apps-script/reference/spreadsheet/text-style) | Returns the text style of this value. |\n| [getTextStyle(startOffset, endOffset)](#getTextStyle(Integer,Integer)) | [TextStyle](/apps-script/reference/spreadsheet/text-style) | Returns the text style of the text from `start``Offset` to `end``Offset`. |\n\nDetailed documentation\n----------------------\n\n### `copy()`\n\nReturns a builder for a Rich Text value initialized with the values of this Rich Text value.\n\n#### Return\n\n\n[RichTextValueBuilder](/apps-script/reference/spreadsheet/rich-text-value-builder) --- A builder for a Rich Text value.\n\n*** ** * ** ***\n\n### `get``End``Index()`\n\nGets the end index of this value in the cell.\n\n#### Return\n\n\n`Integer` --- The end index of this value in the cell.\n\n*** ** * ** ***\n\n### `get``Link``Url()`\n\nReturns the link URL for this value.\n\n#### Return\n\n\n`String` --- The link URL for this value, or `null` if there is no link or if there are\nmultiple different links.\n\n*** ** * ** ***\n\n### `get``Link``Url(startOffset, endOffset)`\n\nReturns the link URL for the text from `start``Offset` to `end``Offset`. Offsets are 0\nbased and relative to the cell's text, with the start offset being inclusive and the end offset\nbeing exclusive.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------|-----------|-------------------|\n| `start``Offset` | `Integer` | The start offset. |\n| `end``Offset` | `Integer` | The end offset. |\n\n#### Return\n\n\n`String` --- The link URL for this value, or `null` if there is no link or if multiple\ndifferent links are in the given range.\n\n*** ** * ** ***\n\n### `get``Runs()`\n\nReturns the Rich Text string split into an array of runs, wherein each run is the longest\npossible substring having a consistent text style.\n\n#### Return\n\n\n[RichTextValue[]](#) --- An array of runs.\n\n*** ** * ** ***\n\n### `get``Start``Index()`\n\nGets the start index of this value in the cell.\n\n#### Return\n\n\n`Integer` --- The start index of this value in the cell.\n\n*** ** * ** ***\n\n### `get``Text()`\n\nReturns the text of this value.\n\n#### Return\n\n\n`String` --- The text of this value.\n\n*** ** * ** ***\n\n### `get``Text``Style()`\n\nReturns the text style of this value.\n\n#### Return\n\n\n[TextStyle](/apps-script/reference/spreadsheet/text-style) --- The text style of this value.\n\n*** ** * ** ***\n\n### `get``Text``Style(startOffset, endOffset)`\n\nReturns the text style of the text from `start``Offset` to `end``Offset`. Offsets are 0\nbased and relative to the cell's text, with the start offset being inclusive and the end offset\nbeing exclusive.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------|-----------|-------------------|\n| `start``Offset` | `Integer` | The start offset. |\n| `end``Offset` | `Integer` | The end offset. |\n\n#### Return\n\n\n[TextStyle](/apps-script/reference/spreadsheet/text-style) --- The text style of the given substring of this value."]]