리치 텍스트 값의 빌더입니다.
메서드
메서드 | 반환 유형 | 간략한 설명 |
---|---|---|
build() | RichTextValue | 이 빌더에서 서식 있는 텍스트 값을 만듭니다. |
setLinkUrl(startOffset, endOffset, linkUrl) | RichTextValueBuilder | 이 값의 지정된 하위 문자열에 대한 링크 URL을 설정하거나 linkUrl 가 null 이면 삭제합니다. |
setLinkUrl(linkUrl) | RichTextValueBuilder | 전체 값의 링크 URL을 설정하거나 linkUrl 가 null 이면 삭제합니다. |
setText(text) | RichTextValueBuilder | 이 값의 텍스트를 설정하고 기존 텍스트 스타일을 지웁니다. |
setTextStyle(startOffset, endOffset, textStyle) | RichTextValueBuilder | 이 값의 지정된 하위 문자열에 텍스트 스타일을 적용합니다. |
setTextStyle(textStyle) | RichTextValueBuilder | 전체 값에 텍스트 스타일을 적용합니다. |
자세한 문서
build()
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();
매개변수
이름 | 유형 | 설명 |
---|---|---|
startOffset | Integer | 하위 문자열의 시작 오프셋입니다. |
endOffset | Integer | 하위 문자열의 종료 오프셋(제외)입니다. |
linkUrl | String | 설정 중인 링크 URL입니다. |
Return
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();
매개변수
이름 | 유형 | 설명 |
---|---|---|
linkUrl | String | 설정 중인 링크 URL입니다. |
Return
RichTextValueBuilder
- 체인용 빌더입니다.
setText(text)
이 값의 텍스트를 설정하고 기존 텍스트 스타일을 지웁니다. 새 서식 있는 텍스트 값을 만들 때
setTextStyle(startOffset, endOffset, textStyle)
전에 호출해야 합니다.
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 이 값의 텍스트입니다. |
Return
RichTextValueBuilder
- 체인용 빌더입니다.
setTextStyle(startOffset, endOffset, textStyle)
이 값의 지정된 하위 문자열에 텍스트 스타일을 적용합니다. 오프셋은 0을 기준으로 하며 셀의 텍스트 값을 기준으로 합니다. textStyle
가 null
이면 아무 작업도 하지 않습니다.
// Creates a Rich Text value for the text "HelloWorld", with "Hello" bolded, and "World" // italicized. var bold = SpreadsheetApp.newTextStyle().setBold(true).build(); var italic = SpreadsheetApp.newTextStyle().setItalic(true).build(); var value = SpreadsheetApp.newRichTextValue() .setText("HelloWorld") .setTextStyle(0, 5, bold) .setTextStyle(5, 10, italic) .build();
매개변수
이름 | 유형 | 설명 |
---|---|---|
startOffset | Integer | 하위 문자열의 시작 오프셋입니다. |
endOffset | Integer | 하위 문자열의 종료 오프셋(제외)입니다. |
textStyle | TextStyle | 설정 중인 텍스트 스타일입니다. |
Return
RichTextValueBuilder
- 체인용 빌더입니다.
setTextStyle(textStyle)
전체 값에 텍스트 스타일을 적용합니다. 이전에 설정된 텍스트 스타일은 textStyle
내의 값으로 직접 덮어쓰는 경우에만 영향을 받습니다. textStyle
가 null
이면 아무 작업도 하지 않습니다.
// Creates a Rich Text value for the text "HelloWorld" with "Hello" bolded and italicized, // and "World" only italicized. var bold = SpreadsheetApp.newTextStyle().setBold(true).build(); var italic = SpreadsheetApp.newTextStyle().setItalic(true).build(); var value = SpreadsheetApp.newRichTextValue() .setText("HelloWorld") .setTextStyle(0, 5, bold) .setTextStyle(italic) .build();
매개변수
이름 | 유형 | 설명 |
---|---|---|
textStyle | TextStyle | 설정 중인 텍스트 스타일입니다. |
Return
RichTextValueBuilder
- 체인용 빌더입니다.