リッチテキスト値のビルダー。
Methods
メソッド | 戻り値の型 | 概要 |
---|---|---|
build() | RichTextValue | このビルダーからリッチテキスト値を作成します。 |
setLinkUrl(startOffset, endOffset, linkUrl) | RichTextValueBuilder | この値で指定された部分文字列のリンク URL を設定するか、linkUrl が null の場合はクリアします。 |
setLinkUrl(linkUrl) | RichTextValueBuilder | 値全体のリンク URL を設定するか、linkUrl が null の場合はクリアします。 |
setText(text) | RichTextValueBuilder | この値のテキストを設定し、既存のテキスト スタイルをすべてクリアします。 |
setTextStyle(startOffset, endOffset, textStyle) | RichTextValueBuilder | この値の指定された部分文字列にテキスト スタイルを適用します。 |
setTextStyle(textStyle) | RichTextValueBuilder | 値全体にテキスト スタイルを適用します。 |
詳細なドキュメント
build()
setLinkUrl(startOffset, endOffset, linkUrl)
この値で指定された部分文字列のリンク URL を設定するか、linkUrl
が 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();
パラメータ
名前 | 型 | 説明 |
---|---|---|
startOffset | Integer | 部分文字列の開始オフセット(この値を含む)。 |
endOffset | Integer | 部分文字列の終了オフセット(両端を除く)。 |
linkUrl | String | 設定されるリンク URL。 |
リターン
RichTextValueBuilder
- チェーン用のこのビルダー。
setLinkUrl(linkUrl)
値全体のリンク URL を設定するか、linkUrl
が 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();
パラメータ
名前 | 型 | 説明 |
---|---|---|
linkUrl | String | 設定されるリンク URL。 |
リターン
RichTextValueBuilder
- チェーン用のこのビルダー。
setText(text)
この値のテキストを設定し、既存のテキスト スタイルをすべてクリアします。新しいリッチテキスト値を作成する場合は、setTextStyle(startOffset, endOffset, textStyle)
の前に呼び出す必要があります。
パラメータ
名前 | 型 | 説明 |
---|---|---|
text | String | この値のテキスト。 |
リターン
RichTextValueBuilder
- チェーン用のこのビルダー。
setTextStyle(startOffset, endOffset, textStyle)
この値の指定された部分文字列にテキスト スタイルを適用します。オフセットは 0 ベースで、セルのテキスト値を基準にします。textStyle
が 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();
パラメータ
名前 | 型 | 説明 |
---|---|---|
startOffset | Integer | 部分文字列の開始オフセット(この値を含む)。 |
endOffset | Integer | 部分文字列の終了オフセット(両端を除く)。 |
textStyle | TextStyle | 設定するテキスト スタイル。 |
リターン
RichTextValueBuilder
- チェーン用のこのビルダー。
setTextStyle(textStyle)
値全体にテキスト スタイルを適用します。以前に設定したテキスト スタイルは、textStyle
内の値によって直接上書きされる場合にのみ影響を受けます。textStyle
が 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();
パラメータ
名前 | 型 | 説明 |
---|---|---|
textStyle | TextStyle | 設定するテキスト スタイル。 |
リターン
RichTextValueBuilder
- チェーン用のこのビルダー。