Class RichTextValue
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
RichTextValue
สตริงข้อความที่มีการจัดรูปแบบซึ่งใช้เพื่อแสดงข้อความของเซลล์ สตริงย่อยของข้อความอาจมีรูปแบบข้อความที่แตกต่างกัน
รันคือสตริงย่อยที่ยาวที่สุดแบบต่อเนื่องที่มีรูปแบบข้อความเดียวกัน ตัวอย่างเช่น ประโยค "เด็ก คนนี้กำลังถือ แอปเปิล" มีการเรียกใช้ 4 ครั้ง ['This ', 'child ',
'is carrying ', 'apples']
เอกสารประกอบโดยละเอียด
copy()
แสดงผลตัวสร้างสำหรับค่าข้อความที่มีรูปแบบซึ่งเริ่มต้นด้วยค่าของค่าข้อความที่มีรูปแบบนี้
รีเทิร์น
RichTextValueBuilder
— ตัวสร้างค่า Rich Text
getEndIndex()
รับดัชนีสิ้นสุดของค่านี้ในเซลล์
รีเทิร์น
Integer
— ดัชนีสิ้นสุดของค่านี้ในเซลล์
getLinkUrl()
แสดงผล URL ของลิงก์สำหรับค่านี้
รีเทิร์น
String
— URL ของลิงก์สำหรับค่านี้ หรือ null
หากไม่มีลิงก์หรือมีลิงก์หลายรายการ
getLinkUrl(startOffset, endOffset)
แสดง URL ของลิงก์สำหรับข้อความจาก startOffset
ถึง endOffset
ออฟเซ็ตจะอิงตาม 0 และสัมพันธ์กับข้อความของเซลล์ โดยออฟเซ็ตเริ่มต้นจะนับรวมและออฟเซ็ตสิ้นสุดจะไม่นับรวม
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
startOffset | Integer | ออฟเซ็ตเริ่มต้น |
endOffset | Integer | ช่วงเวลาสิ้นสุด |
รีเทิร์น
String
— URL ของลิงก์สำหรับค่านี้ หรือ null
หากไม่มีลิงก์หรือมีลิงก์หลายรายการที่แตกต่างกันในช่วงที่ระบุ
getRuns()
แสดงผลสตริงข้อความริชมีเดียที่แบ่งออกเป็นอาร์เรย์ของรันไทม์ โดยที่รันไทม์แต่ละรายการคือสตริงย่อยที่ยาวที่สุดซึ่งมีสไตล์ข้อความที่สอดคล้องกัน
รีเทิร์น
RichTextValue[]
— อาร์เรย์ของรันไทม์
getStartIndex()
รับดัชนีเริ่มต้นของค่านี้ในเซลล์
รีเทิร์น
Integer
— ดัชนีเริ่มต้นของค่านี้ในเซลล์
getText()
แสดงผลข้อความของค่านี้
รีเทิร์น
String
— ข้อความของค่านี้
getTextStyle()
แสดงผลรูปแบบข้อความของค่านี้
รีเทิร์น
TextStyle
— รูปแบบข้อความของค่านี้
getTextStyle(startOffset, endOffset)
แสดงรูปแบบข้อความของข้อความจาก startOffset
เป็น endOffset
ออฟเซ็ตจะอิงตาม 0 และสัมพันธ์กับข้อความของเซลล์ โดยออฟเซ็ตเริ่มต้นจะนับรวมและออฟเซ็ตสิ้นสุดจะไม่นับรวม
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
startOffset | Integer | ออฟเซ็ตเริ่มต้น |
endOffset | Integer | ช่วงเวลาสิ้นสุด |
รีเทิร์น
TextStyle
— รูปแบบข้อความของสตริงย่อยที่ระบุของค่านี้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 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."]]