เครื่องมือสร้างค่า Rich Text
เมธอด
| วิธีการ | ประเภทการแสดงผล | รายละเอียดแบบย่อ |
|---|---|---|
build() | Rich | สร้างค่า Rich Text จากตัวสร้างนี้ |
set | Rich | ตั้งค่า URL ของลิงก์สำหรับสตริงย่อยที่ระบุของค่านี้ หรือล้างค่าหาก link เป็น
null |
set | Rich | ตั้งค่า URL ของลิงก์สำหรับทั้งค่า หรือล้างค่าหาก link เป็น null |
set | Rich | ตั้งค่าข้อความสำหรับค่านี้และล้างรูปแบบข้อความที่มีอยู่ |
set | Rich | ใช้รูปแบบข้อความกับสตริงย่อยที่ระบุของค่านี้ |
set | Rich | ใช้รูปแบบข้อความกับค่าทั้งหมด |
เอกสารโดยละเอียด
build()
สร้างค่า Rich Text จากตัวสร้างนี้
รีเทิร์น
RichTextValue — ค่าข้อความที่มีรูปแบบที่สร้างจากเครื่องมือสร้างนี้
setLinkUrl(startOffset, endOffset, linkUrl)
ตั้งค่า URL ของลิงก์สำหรับสตริงย่อยที่ระบุของค่านี้ หรือล้างค่าหาก linkUrl เป็น
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();
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
start | Integer | ค่าชดเชยการเริ่มต้นสำหรับสตริงย่อย (รวมค่าเริ่มต้น) |
end | Integer | ออฟเซ็ตสิ้นสุดของสตริงย่อย (ไม่รวม) |
link | String | URL ของลิงก์ที่กำลังตั้งค่า |
รีเทิร์น
RichTextValueBuilder - เครื่องมือสร้างนี้สำหรับการเชื่อมโยง
setLinkUrl(linkUrl)
ตั้งค่า URL ของลิงก์สำหรับทั้งค่า หรือล้างค่าหาก linkUrl เป็น 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();
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
link | String | URL ของลิงก์ที่กำลังตั้งค่า |
รีเทิร์น
RichTextValueBuilder - เครื่องมือสร้างนี้สำหรับการเชื่อมโยง
setText(text)
ตั้งค่าข้อความสำหรับค่านี้และล้างรูปแบบข้อความที่มีอยู่ เมื่อสร้างค่า Rich Text ใหม่ ควรเรียกใช้เมธอดนี้ก่อน setTextStyle(startOffset, endOffset, textStyle)
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
text | String | ข้อความสำหรับค่านี้ |
รีเทิร์น
RichTextValueBuilder - เครื่องมือสร้างนี้สำหรับการเชื่อมโยง
setTextStyle(startOffset, endOffset, textStyle)
ใช้รูปแบบข้อความกับสตริงย่อยที่ระบุของค่านี้ ออฟเซ็ตเป็นแบบอิงตาม 0 และสัมพันธ์
กับค่าข้อความของเซลล์ ไม่ดำเนินการใดๆ หาก textStyle เป็น 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();
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
start | Integer | ค่าชดเชยการเริ่มต้นสำหรับสตริงย่อย (รวมค่าเริ่มต้น) |
end | Integer | ออฟเซ็ตสิ้นสุดของสตริงย่อย (ไม่รวม) |
text | Text | รูปแบบข้อความที่กำลังตั้งค่า |
รีเทิร์น
RichTextValueBuilder - เครื่องมือสร้างนี้สำหรับการเชื่อมโยง
setTextStyle(textStyle)
ใช้รูปแบบข้อความกับค่าทั้งหมด รูปแบบข้อความที่ตั้งค่าไว้ก่อนหน้านี้จะได้รับผลกระทบก็ต่อเมื่อค่าภายใน textStyle เขียนทับโดยตรง ไม่ดำเนินการใดๆ หาก textStyle
เป็น 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();
พารามิเตอร์
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
text | Text | รูปแบบข้อความที่กำลังตั้งค่า |
รีเทิร์น
RichTextValueBuilder - เครื่องมือสร้างนี้สำหรับการเชื่อมโยง