Class RichTextValueBuilder

リッチテキストビルダー

リッチテキスト値のビルダー。

メソッド

メソッド戻り値の型概要
build()RichTextValueこのビルダーからリッチテキスト値を作成します。
setLinkUrl(startOffset, endOffset, linkUrl)RichTextValueBuilderこの値の指定されたサブ文字列のリンク URL を設定します。linkUrlnull の場合、クリアします。
setLinkUrl(linkUrl)RichTextValueBuilder値全体のリンク URL を設定します。linkUrlnull の場合は、値を消去します。
setText(text)RichTextValueBuilderこの値のテキストを設定し、既存のテキスト スタイルをすべて消去します。
setTextStyle(startOffset, endOffset, textStyle)RichTextValueBuilderこの値の指定された部分文字列にテキスト スタイルを適用します。
setTextStyle(textStyle)RichTextValueBuilder値全体にテキスト スタイルを適用します。

詳細なドキュメント

build()

このビルダーからリッチテキスト値を作成します。

戻る

RichTextValue - このビルダーから作成されたリッチテキスト値。


setLinkUrl(startOffset, endOffset, linkUrl)

この値の指定されたサブ文字列のリンク URL を設定します。linkUrlnull の場合、リンク URL はクリアされます。

// 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();

パラメータ

名前説明
startOffsetIntegerサブ文字列の開始オフセット(この値を含む)。
endOffsetIntegerサブ文字列の終了オフセット(この値は含まれません)。
linkUrlString設定されるリンク URL。

戻る

RichTextValueBuilder - チェーン用のこのビルダー。


setLinkUrl(linkUrl)

値全体のリンク URL を設定します。linkUrlnull の場合は、値を消去します。

// 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();

パラメータ

名前説明
linkUrlString設定されるリンク URL。

戻る

RichTextValueBuilder - チェーン用のこのビルダー。


setText(text)

この値のテキストを設定し、既存のテキスト スタイルをすべて消去します。新しいリッチテキスト値を作成する場合は、setTextStyle(startOffset, endOffset, textStyle) の前に呼び出す必要があります。

パラメータ

名前説明
textStringこの値のテキスト。

戻る

RichTextValueBuilder - チェーン用のこのビルダー。


setTextStyle(startOffset, endOffset, textStyle)

この値の指定された部分文字列にテキスト スタイルを適用します。オフセットは 0 ベースで、セルのテキスト値を基準とします。textStylenull の場合は何もしません。

// 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();

パラメータ

名前説明
startOffsetIntegerサブ文字列の開始オフセット(この値を含む)。
endOffsetIntegerサブ文字列の終了オフセット(この値は含まれません)。
textStyleTextStyle設定されるテキスト スタイル。

戻る

RichTextValueBuilder - チェーン用のこのビルダー。


setTextStyle(textStyle)

値全体にテキスト スタイルを適用します。以前に設定されたテキスト スタイルは、textStyle 内の値によって直接上書きされた場合にのみ影響を受けます。textStylenull の場合は何もしません。

// 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();

パラメータ

名前説明
textStyleTextStyle設定されるテキスト スタイル。

戻る

RichTextValueBuilder - チェーン用のこのビルダー。