Um criador de valores de rich text.
Métodos
| Método | Tipo de retorno | Breve descrição |
|---|---|---|
build() | Rich | Cria um valor de rich text com base neste builder. |
set | Rich | Define o URL do link para a determinada substring desse valor ou o limpa se link for
null. |
set | Rich | Define o URL do link para todo o valor ou o limpa se link for null. |
set | Rich | Define o texto para esse valor e limpa qualquer estilo de texto atual. |
set | Rich | Aplica um estilo de texto à substring especificada desse valor. |
set | Rich | Aplica 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
| Nome | Tipo | Descrição |
|---|---|---|
start | Integer | O deslocamento inicial da substring, inclusive. |
end | Integer | O deslocamento final da substring, exclusivo. |
link | String | O 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
| Nome | Tipo | Descrição |
|---|---|---|
link | String | O 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
| Nome | Tipo | Descrição |
|---|---|---|
text | String | O 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
| Nome | Tipo | Descrição |
|---|---|---|
start | Integer | O deslocamento inicial da substring, inclusive. |
end | Integer | O deslocamento final da substring, exclusivo. |
text | Text | O 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
| Nome | Tipo | Descrição |
|---|---|---|
text | Text | O estilo de texto que está sendo definido. |
Retornar
RichTextValueBuilder: este builder, para encadeamento.