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

More than one databar destroys the workbook #520

Open
joshuasami opened this issue Feb 2, 2025 · 2 comments
Open

More than one databar destroys the workbook #520

joshuasami opened this issue Feb 2, 2025 · 2 comments

Comments

@joshuasami
Copy link

Describtion
Hey, I'm running in to a problem, when I add databars, via conditionalFormatting, into my workbook. One Databar works fine, but I when I add two Databars, my workbook saves, but I can't open it anymore afterwards.

The same bug was already described here: /issues/42

To Reproduce

library(openxlsx)
wb <- createWorkbook()
sheet_name <- "sheet 1"
addWorksheet(wb, sheet_name)
df <- data.frame(
  A = 1:10,
  B = 11:20
)
writeDataTable(wb, sheet_name, df, tableStyle = "TableStyleMedium9")
for (col in 1:2) {
  conditionalFormatting(
    wb,
    sheet_name,
    cols = col,
    rows = 2:(nrow(df) + 1),
    type = "databar",
    style = c("#ffb628", "#ffb628"),
    gradient = FALSE,
    border = FALSE
  )
}
saveWorkbook(wb, "test.xlsx", overwrite = TRUE)
@JanMarvin
Copy link
Collaborator

Hi @josuame, thanks for the report, but this is not going to be fixed in openxlsx. If you need this, please have a look at openxlsx2.

It requires working with the XML code that is just not possible with the tools available in openxlsx.

@JanMarvin
Copy link
Collaborator

If you want to, I would accept a PR either mentioning this is in the documentation or via a check when adding a second databar.
IIRC the databar is added as additional ext14 node, when instead it should be added as a child.

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

No branches or pull requests

2 participants