서식 있는 텍스트 값의 빌더입니다.
메서드
| 메서드 | 반환 유형 | 간략한 설명 |
|---|---|---|
build() | Rich | 이 빌더에서 서식 있는 텍스트 값을 만듭니다. |
set | Rich | 이 값의 지정된 하위 문자열에 대한 링크 URL을 설정하거나 link이
null인 경우 링크 URL을 지웁니다. |
set | Rich | 전체 값의 링크 URL을 설정하거나 link이 null인 경우 링크 URL을 지웁니다. |
set | Rich | 이 값의 텍스트를 설정하고 기존 텍스트 스타일을 지웁니다. |
set | Rich | 이 값의 지정된 하위 문자열에 텍스트 스타일을 적용합니다. |
set | Rich | 전체 값에 텍스트 스타일을 적용합니다. |
자세한 문서
build()
setLinkUrl(startOffset, endOffset, linkUrl)
이 값의 지정된 하위 문자열에 대한 링크 URL을 설정하거나 linkUrl이 null인 경우 링크 URL을 지웁니다.
// 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인 경우 링크 URL을 지웁니다.
// 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)
이 값의 텍스트를 설정하고 기존 텍스트 스타일을 지웁니다. 새 서식 있는 텍스트 값을 만들 때는 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 — 체이닝에 이 빌더가 반환됩니다.