リッチテキスト値のビルダー。
メソッド
| メソッド | 戻り値の型 | 概要 |
|---|---|---|
build() | Rich | このビルダーからリッチテキスト値を作成します。 |
set | Rich | この値の指定されたサブストリングのリンク URL を設定します。link が
nullの場合はクリアします。 |
set | Rich | 値全体のリンク URL を設定します。link が null の場合はクリアします。 |
set | Rich | この値のテキストを設定し、既存のテキスト スタイルをクリアします。 |
set | Rich | この値の指定されたサブストリングにテキスト スタイルを適用します。 |
set | Rich | 値全体にテキスト スタイルを適用します。 |
詳細なドキュメント
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();
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
start | Integer | サブストリングの開始オフセット(この値を含む)。 |
end | Integer | サブストリングの終了オフセット(この値は含まれない)。 |
link | 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();
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
link | 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. 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();
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
start | Integer | サブストリングの開始オフセット(この値を含む)。 |
end | Integer | サブストリングの終了オフセット(この値は含まれない)。 |
text | Text | 設定するテキスト スタイル。 |
戻る
RichTextValueBuilder - チェーン用のこのビルダー。
setTextStyle(textStyle)
値全体にテキスト スタイルを適用します。以前に設定したテキスト スタイルは、textStyle 内の値で直接上書きされた場合にのみ影響します。textStyle が 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();
パラメータ
| 名前 | タイプ | 説明 |
|---|---|---|
text | Text | 設定するテキスト スタイル。 |
戻る
RichTextValueBuilder - チェーン用のこのビルダー。