Class RichTextValueBuilder

RichTextValueBuilder

Um builder para valores de rich text.

Métodos

MétodoTipo de retornoBreve descrição
build()RichTextValueCria um valor de rich text a partir desse builder.
setLinkUrl(startOffset, endOffset, linkUrl)RichTextValueBuilderDefine o URL do link para a substring especificada desse valor ou o limpa se linkUrl for null.
setLinkUrl(linkUrl)RichTextValueBuilderDefine o URL do link para o valor inteiro ou o limpa se linkUrl for null.
setText(text)RichTextValueBuilderDefine o texto para esse valor e limpa qualquer estilo de texto existente.
setTextStyle(startOffset, endOffset, textStyle)RichTextValueBuilderAplica um estilo de texto à substring especificada desse valor.
setTextStyle(textStyle)RichTextValueBuilderAplica um estilo de texto ao valor inteiro.

Documentação detalhada

build()

Cria um valor de rich text a partir desse builder.

Retorno

RichTextValue: um valor de rich text criado a partir do builder.


setLinkUrl(startOffset, endOffset, linkUrl)

Define o URL do link para a substring especificada desse valor ou o limpa se linkUrl for 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();

Parâmetros

NomeTipoDescrição
startOffsetIntegerO deslocamento inicial da substring, inclusive.
endOffsetIntegerO deslocamento final da substring, exclusivo.
linkUrlStringO URL do link que está sendo definido.

Retorno

RichTextValueBuilder: este builder, para encadeamento.


setLinkUrl(linkUrl)

Define o URL do link para o valor inteiro ou o limpa se linkUrl for 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();

Parâmetros

NomeTipoDescrição
linkUrlStringO URL do link que está sendo definido.

Retorno

RichTextValueBuilder: este builder, para encadeamento.


setText(text)

Define o texto para esse valor e limpa qualquer estilo de texto existente. Ao criar um novo valor de rich text, ele precisa ser chamado antes de setTextStyle(startOffset, endOffset, textStyle).

Parâmetros

NomeTipoDescrição
textStringO texto para esse valor.

Retorno

RichTextValueBuilder: este builder, para encadeamento.


setTextStyle(startOffset, endOffset, textStyle)

Aplica um estilo de texto à substring especificada desse valor. Os deslocamentos são baseados em 0 e são relativos ao valor do texto da célula. Não faz nada se textStyle for 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();

Parâmetros

NomeTipoDescrição
startOffsetIntegerO deslocamento inicial da substring, inclusive.
endOffsetIntegerO deslocamento final da substring, exclusivo.
textStyleTextStyleO estilo de texto que está sendo definido.

Retorno

RichTextValueBuilder: este builder, para encadeamento.


setTextStyle(textStyle)

Aplica um estilo de texto ao valor inteiro. Os estilos de texto definidos anteriormente só serão afetados se forem substituídos diretamente por valores em textStyle. Não fará nada se textStyle for 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();

Parâmetros

NomeTipoDescrição
textStyleTextStyleO estilo de texto que está sendo definido.

Retorno

RichTextValueBuilder: este builder, para encadeamento.