Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R/conditional_formatting] fix multiple databar entries per sheet #174

Merged
merged 3 commits into from
May 12, 2022

Conversation

JanMarvin
Copy link
Owner

Tested with:

library(openxlsx2)

wb <- wb_workbook()
wb$add_worksheet("databar")
## Databars
wb$add_data("databar", -5:5, startCol = 1)
wb_conditional_formatting(
  wb,
  "databar",
  cols = 1,
  rows = 1:11,
  type = "databar"
) ## Default colours

wb$add_data("databar", -5:5, startCol = 3)
wb_conditional_formatting(
  wb,
  "databar",
  cols = 3,
  rows = 1:11,
  type = "databar",
  showValue = FALSE,
  gradient = FALSE
) ## Default colours

wb$add_data("databar", -5:5, startCol = 5)
wb_conditional_formatting(
  wb, 
  "databar",
  cols = 5,
  rows = 1:11,
  type = "databar",
  style = c("#a6a6a6"),
  showValue = FALSE
)

wb$add_data("databar", -5:5, startCol = 7)
wb_conditional_formatting(
  wb,
  "databar",
  cols = 7,
  rows = 1:11,
  type = "databar",
  style = c("red"),
  showValue = TRUE,
  gradient = FALSE
)

wb$add_data("databar", -5:5, startCol = 9)
wb_conditional_formatting(
  wb,
  "databar",
  cols = 9,
  rows = 1:11,
  type = "databar",
  style = c("#a6a6a6", "#a6a6a6"),
  showValue = FALSE, 
  gradient = FALSE
)

wb$open()

@codecov-commenter
Copy link

Codecov Report

Merging #174 (f5107cc) into main (437eb13) will increase coverage by 0.22%.
The diff coverage is 97.91%.

@@            Coverage Diff             @@
##             main     #174      +/-   ##
==========================================
+ Coverage   77.52%   77.74%   +0.22%     
==========================================
  Files          36       36              
  Lines        7342     7424      +82     
==========================================
+ Hits         5692     5772      +80     
- Misses       1650     1652       +2     
Impacted Files Coverage Δ
R/class-workbook.R 73.83% <94.73%> (+0.11%) ⬆️
R/pugixml.R 100.00% <100.00%> (ø)
src/pugi.cpp 100.00% <100.00%> (ø)
src/openxlsx2_types.h 100.00% <0.00%> (ø)
R/wb_functions.R 88.11% <0.00%> (+0.02%) ⬆️
R/wb_load.R 94.69% <0.00%> (+0.10%) ⬆️
src/load_workbook.cpp 92.46% <0.00%> (+0.21%) ⬆️
src/write_file.cpp 94.23% <0.00%> (+1.59%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 437eb13...f5107cc. Read the comment docs.

level = "x14:conditionalFormattings")
self$worksheets[[sheet]]$extLst <- extLst
}

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would have been to select the xml_nodes for x14:conditionalFormatting, combine them in a new x14:conditionalFormattings and replace this node inside the extLst using something like this: 2ead3d1

@JanMarvin JanMarvin linked an issue May 11, 2022 that may be closed by this pull request
@JanMarvin JanMarvin merged commit 5c37674 into main May 12, 2022
@JanMarvin JanMarvin deleted the cf_databar branch May 12, 2022 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extLst with cf:databar breaks xlsx
2 participants