There are two types of formatting: 'style' formatting, such as Excel's
built-in styles 'normal', 'bad', etc., and 'local' formatting, which
overrides the style. These are returned in the $style
and $local
sublists of xlsx_formats()
, with identical structures.
To look up the local formatting of a given cell, take the cell's
local_format_id
value (my_cells$Sheet1[1, "local_format_id"]
), and use it
as an index into the format structure. E.g. to look up the font size,
my_formats$local$font$size[local_format_id]
. To see all available formats,
type str(my_formats$local)
.
Colours may be recorded in any of three ways: a hexadecimal RGB string with
or without alpha, an 'indexed' colour, and an index into a 'theme'.
xlsx_formats()
dereferences 'indexed' and 'theme' colours to their
hexadecimal RGB string representation, and standardises all RGB strings to
have an alpha channel in the first two characters. The 'index' and the
'theme' name are still provided. To filter by an RGB string, you could look
up the RGB values in a spreadsheet program (e.g. Excel, LibreOffice,
Gnumeric), and use the grDevices::rgb()
function to convert these to a
hexadecimal string.
A <- 1; R <- 0.5; G <- 0; B <- 0
rgb(A, R, G, B)
# [1] "#FF800000"