Class RichTextValueBuilder

RichTextValueBuilder

서식 있는 텍스트 값의 빌더입니다.

방법

메서드반환 유형간략한 설명
build()RichTextValue이 빌더에서 서식 있는 텍스트 값을 만듭니다.
setLinkUrl(startOffset, endOffset, linkUrl)RichTextValueBuilder이 값의 지정된 하위 문자열에 대한 링크 URL을 설정하거나 linkUrlnull인 경우 삭제합니다.
setLinkUrl(linkUrl)RichTextValueBuilder전체 값의 링크 URL을 설정하거나 linkUrlnull인 경우 삭제합니다.
setText(text)RichTextValueBuilder이 값의 텍스트를 설정하고 기존 텍스트 스타일을 지웁니다.
setTextStyle(startOffset, endOffset, textStyle)RichTextValueBuilder이 값의 지정된 하위 문자열에 텍스트 스타일을 적용합니다.
setTextStyle(textStyle)RichTextValueBuilder전체 값에 텍스트 스타일을 적용합니다.

자세한 문서

build()

이 빌더에서 서식 있는 텍스트 값을 만듭니다.

리턴

RichTextValue - 이 빌더에서 생성된 서식 있는 텍스트 값입니다.


setLinkUrl(startOffset, endOffset, linkUrl)

이 값의 지정된 하위 문자열에 대한 링크 URL을 설정하거나 linkUrlnull인 경우 삭제합니다.

// 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();

매개변수

이름유형설명
startOffsetInteger하위 문자열의 시작 오프셋입니다(해당 값 포함).
endOffsetInteger하위 문자열의 끝 오프셋입니다(제외).
linkUrlString설정 중인 링크 URL입니다.

리턴

RichTextValueBuilder - 체이닝을 위한 빌더입니다.


setLinkUrl(linkUrl)

전체 값의 링크 URL을 설정하거나 linkUrlnull인 경우 삭제합니다.

// 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();

매개변수

이름유형설명
linkUrlString설정 중인 링크 URL입니다.

리턴

RichTextValueBuilder - 체이닝을 위한 빌더입니다.


setText(text)

이 값의 텍스트를 설정하고 기존 텍스트 스타일을 지웁니다. 새로운 서식 있는 텍스트 값을 만들 때는 setTextStyle(startOffset, endOffset, textStyle) 전에 호출해야 합니다.

매개변수

이름유형설명
textString이 값의 텍스트입니다.

리턴

RichTextValueBuilder - 체이닝을 위한 빌더입니다.


setTextStyle(startOffset, endOffset, textStyle)

이 값의 지정된 하위 문자열에 텍스트 스타일을 적용합니다. 오프셋은 0을 기반으로 하며 셀의 텍스트 값을 기준으로 합니다. textStylenull이면 아무 작업도 하지 않습니다.

// 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();

매개변수

이름유형설명
startOffsetInteger하위 문자열의 시작 오프셋입니다(해당 값 포함).
endOffsetInteger하위 문자열의 끝 오프셋입니다(제외).
textStyleTextStyle설정 중인 텍스트 스타일입니다.

리턴

RichTextValueBuilder - 체이닝을 위한 빌더입니다.


setTextStyle(textStyle)

전체 값에 텍스트 스타일을 적용합니다. 이전에 설정된 텍스트 스타일은 textStyle 내의 값으로 직접 덮어쓰는 경우에만 영향을 받습니다. textStylenull이면 아무 작업도 하지 않습니다.

// 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();

매개변수

이름유형설명
textStyleTextStyle설정 중인 텍스트 스타일입니다.

리턴

RichTextValueBuilder - 체이닝을 위한 빌더입니다.