Class RichTextValueBuilder

RichTextValueBuilder

Um criador de valores de rich text.

Métodos

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

Documentação detalhada

build()

Cria um valor de rich text com base neste builder.

Retornar

RichTextValue: um valor de rich text criado com base neste builder.


setLinkUrl(startOffset, endOffset, linkUrl)

Define o URL do link para a determinada substring 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.

Retornar

RichTextValueBuilder: este builder, para encadeamento.


setLinkUrl(linkUrl)

Define o URL do link para todo o valor 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.

Retornar

RichTextValueBuilder: este builder, para encadeamento.


setText(text)

Define o texto para esse valor e limpa qualquer estilo de texto atual. Ao criar um novo valor de texto formatado, isso precisa ser chamado antes de setTextStyle(startOffset, endOffset, textStyle).

Parâmetros

NomeTipoDescrição
textStringO texto desse valor.

Retornar

RichTextValueBuilder: este builder, para encadeamento.


setTextStyle(startOffset, endOffset, textStyle)

Aplica um estilo de texto à substring especificada desse valor. Os deslocamentos são baseados em zero e relativos ao valor de 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.
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();

Parâmetros

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

Retornar

RichTextValueBuilder: este builder, para encadeamento.


setTextStyle(textStyle)

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

Parâmetros

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

Retornar

RichTextValueBuilder: este builder, para encadeamento.