Skip to contents

`xl_rich_string()` builds the value of a single cell out of differently formatted runs, so that one cell can read "This is **bold** text". Pass it as the `value` of [xl_cell_general()].

Excel requires at least two runs: a string with one format is an ordinary character value, so pass it as one.

Usage

xl_rich_string(...)

is_xl_rich_string(x)

Arguments

...

Runs, in order. A bare string is taken as an unformatted run; an [xl_rich_run()] carries its own font. Lists of either are flattened, so runs can be assembled programmatically.

x

An object to test.

Value

An `xl_rich_string` object: a list of runs.

See also

[xl_rich_run], [xl_cell_general], [xl_font]

Other cell content: is_xl_comment(), xl_cell_general(), xl_comment(), xl_formula(), xl_rich_run()

Examples

xl_rich_string("This is ", xl_rich_run("bold", xl_font(bold = TRUE)), " text")
#> <xl_rich_string: 3 runs>
#>   "This is "
#>   "bold"  <formatted>
#>   " text"

# in a cell, with a cell-wide format alongside the per-run fonts
xl_cell_general(
  value  = xl_rich_string("2 H", xl_rich_run("2", xl_font(script = "sub")), "O"),
  format = xl_align(horizontal = "center")
)
#> [xl_cell_general: 1 cell]
#>   [1] value=2 H2O, format=<set>