Learn R Programming

writexl (version 2.0.0)

xl_color: Normalize a color to a libxlsxwriter RGB integer

Description

Converts an R color name (e.g. `"navy"`), a hex string (`"#FF0000"` or `"FF0000"`), or an integer in the range `0x000000`..`0xFFFFFF` into the single `0xRRGGBB` integer that libxlsxwriter expects. Used internally by every `color`/`background`/`foreground` argument of the formatting constructors, and exported so it can be used directly.

Usage

xl_color(x)

Value

A single integer in `0x000000`..`0xFFFFFF`, or `NA_integer_`.

Arguments

x

A single color: an R color name, a hex string, or an integer. `NA` returns `NA_integer_` (an unset color).

See Also

Other cell formatting: is_xl_format(), xl_format(), xl_format_groups

Examples

Run this code
xl_color("red")
xl_color("#0000FF")
xl_color(255L)

Run the code above in your browser using DataLab