applyXlsxCategoricalFormat | R Documentation |
Add categorical colors to Excel xlsx worksheets
applyXlsxCategoricalFormat(
xlsxFile,
sheet = 1,
rowRange = NULL,
colRange = NULL,
colorSub = NULL,
colorSubText = setTextContrastColor(colorSub),
trimCatNames = TRUE,
overwrite = TRUE,
wrapText = FALSE,
stack = TRUE,
verbose = FALSE,
...
)
xlsxFile |
|
sheet |
|
rowRange , colRange |
|
colorSub |
one of the following types of input:
|
colorSubText |
optional |
trimCatNames |
|
overwrite |
|
wrapText |
|
stack |
|
verbose |
|
... |
additional arguments are ignored. |
style_coord_list |
|
styles_list |
|
wb , sheet , stack |
arguments passed to |
This function is a convenient wrapper for applying categorical
color formatting to cell background colors, and applies a contrasting
color to the text in cells using jamba::setTextContrastColor()
.
It uses a named character vector of colors supplied as colorSub
to define cell background colors, and optionally colorSubText
to define a specific color for the cell text.
Workbook
object as defined by the openxlsx
package
is returned invisibly with invisible()
. This Workbook
can be used in argument wb
to provide a speed boost when
saving multiple sheets to the same file.
list
named by the primary fill color of each cell,
containing a openxlsx::style
object suitable for use
by openxlsx::addStyle()
.
list
named by style, by default the hex color with no alpha
where each element is a matrix
with colnames row
and col
indicating individual row/column coordinate positions.
NULL
, this function is called for the by-product
of adjusting
Other jam export functions:
applyXlsxConditionalFormat()
,
readOpenxlsx()
,
set_xlsx_colwidths()
,
set_xlsx_rowheights()
,
writeOpenxlsx()
## Not run:
df <- data.frame(a=LETTERS[1:5], b=1:5);
jamba::writeOpenxlsx(x=df,
file="jamba_test.xlsx",
sheetName="test_jamba");
colorSub <- nameVector(
rainbow(5, s=c(0.8, 1), v=c(0.8, 1)),
LETTERS[1:5]);
applyXlsxCategoricalFormat(
xlsxFile="jamba_test.xlsx",
sheet="test_jamba",
colorSub=colorSub
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.