Closed LafontRapnouilTristan closed 2 years ago
ERRATUM: Following further investigation I just found a Stackoverflow question dealing with this issue. It is about using Fgfill instead of bgFill when using addStyle and not ConditionalFormatting. Not intuitive but it worked!!
Hi, first, thanks for this amazing package and work!!
I encounter some issues to color specific cell position within .xlsx file with addstyle while it work whit conditional formatting.
Expected Behavior
My cells should be colored according to specified bgFill style. I have tried many times, and cell positioning is good but bgFill is always black. Whatever "Style" I supply to the function.
Actual Behavior
It works perfectly fine with conditional formatting but with addStyle it returns a black colored cell while the used style is the same. As I want to color wide range of specific cell coordinates, I'd prefer to use addstyle rather than a workaround with conditional formatting.
Steps to Reproduce the Problem
(please attach an example xlsx file if possible)
Create style
the_style <- openxlsx::createStyle(bgFill = "#E3E338") # a yellowish bgFill
dumdum <- openxlsx::buildWorkbook(data.frame(x = 1, y = 1:10))
Applying style via
addStyle
to the first column, fifth rowApplying style via
conditionalFormatting
to the first column, fourth rowopenxlsx::saveWorkbook(dumdum , "../../wow.xlsx", overwrite = T)
sessionInfo()
R version 4.1.1 (2021-08-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale: [1] LC_COLLATE=English_Europe.1252 [2] LC_CTYPE=English_Europe.1252
[3] LC_MONETARY=English_Europe.1252 [4] LC_NUMERIC=C
[5] LC_TIME=English_Europe.1252
attached base packages: [1] stats graphics grDevices utils datasets methods
[7] base
other attached packages: [1] magrittr_2.0.2 EcophyCofog_0.0.0.9000
loaded via a namespace (and not attached): [1] zip_2.2.0 Rcpp_1.0.8.2 pillar_1.7.0
[4] compiler_4.1.1 cellranger_1.1.0 tools_4.1.1
[7] lifecycle_1.0.1 tibble_3.1.6 gtable_0.3.0
[10] pkgconfig_2.0.3 rlang_1.0.2 openxlsx_4.2.5
[13] DBI_1.1.2 cli_3.2.0 rstudioapi_0.13
[16] dplyr_1.0.8 stringr_1.4.0 generics_0.1.2
[19] vctrs_0.3.8 hms_1.1.1 combinat_0.0-8
[22] grid_4.1.1 tidyselect_1.1.2 data.table_1.14.2 [25] glue_1.6.2 R6_2.5.1 fansi_1.0.2
[28] readxl_1.3.1 farver_2.1.0 ggplot2_3.3.5
[31] purrr_0.3.4 readr_2.1.2 tzdb_0.2.0
[34] scales_1.2.0 ellipsis_0.3.2 rlist_0.4.6.2
[37] assertthat_0.2.1 colorspace_2.0-3 utf8_1.2.2
[40] stringi_1.7.6 munsell_0.5.0 crayon_1.5.1