Um builder para valores de rich text.
Métodos
Método | Tipo de retorno | Breve descrição |
---|---|---|
build() | RichTextValue | Cria um valor de rich text a partir desse builder. |
setLinkUrl(startOffset, endOffset, linkUrl) | RichTextValueBuilder | Define o URL do link para a substring especificada desse valor ou o limpa se linkUrl for
null . |
setLinkUrl(linkUrl) | RichTextValueBuilder | Define o URL do link para o valor inteiro ou o limpa se linkUrl for null . |
setText(text) | RichTextValueBuilder | Define o texto para esse valor e limpa qualquer estilo de texto existente. |
setTextStyle(startOffset, endOffset, textStyle) | RichTextValueBuilder | Aplica um estilo de texto à substring especificada desse valor. |
setTextStyle(textStyle) | RichTextValueBuilder | Aplica 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
Nome | Tipo | Descrição |
---|---|---|
startOffset | Integer | O deslocamento inicial da substring, inclusive. |
endOffset | Integer | O deslocamento final da substring, exclusivo. |
linkUrl | String | O 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
Nome | Tipo | Descrição |
---|---|---|
linkUrl | String | O 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
Nome | Tipo | Descrição |
---|---|---|
text | String | O 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
Nome | Tipo | Descrição |
---|---|---|
startOffset | Integer | O deslocamento inicial da substring, inclusive. |
endOffset | Integer | O deslocamento final da substring, exclusivo. |
textStyle | TextStyle | O 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
Nome | Tipo | Descrição |
---|---|---|
textStyle | TextStyle | O estilo de texto que está sendo definido. |
Retorno
RichTextValueBuilder
: este builder, para encadeamento.