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

Illegal XML characters remain in vectors with formula class #845

Closed
tpsteiner opened this issue Nov 8, 2023 · 3 comments
Closed

Illegal XML characters remain in vectors with formula class #845

tpsteiner opened this issue Nov 8, 2023 · 3 comments
Labels
question ❓ Further information is requested

Comments

@tpsteiner
Copy link

I am working on a project that uses write_xlsx() to create an excel data table with formulas. The XML file of the worksheet opens with this error:
image

Below is some reproducible code showing two working cases and one error case. When opening temp_path3, you should encounter the same error as above. Looking in the XML file, the & inside the "formula" column is not converted to &

library(openxlsx2)

# No error with & using character class
data1 <- tibble::tribble( ~right, '=CONCAT("Johnson & Johnson", 1)')
temp_path1 <- temp_xlsx()
write_xlsx(data1, temp_path1)
xl_open(temp_path1)

# No error with 'and' instead of & using formula class
data2 <- tibble::tribble( ~right, '=RIGHT("Johnson and Johnson", 2)')
temp_path2 <- temp_xlsx()
class(data2$right) <- c(class(data2$right), "formula")
write_xlsx(data2, temp_path2)
xl_open(temp_path2)

# Error XML illegal character & instead of &amp; using formula class
data3 <- tibble::tribble( ~right, '=RIGHT("Johnson & Johnson", 3)')
temp_path3 <- temp_xlsx()
class(data3$right) <- c(class(data2$right), "formula")
write_xlsx(data3, temp_path3)
xl_open(temp_path3)
> packageVersion("openxlsx2")
[1] ‘1.1

This package has been very useful. Thanks for all that you do!

@JanMarvin
Copy link
Owner

Hi @tpsteiner , thanks for the kind words! I assume that the issue is another duplicate of the issue that was solved in #834 . Could you please check if this is solved with our development branch?

@JanMarvin JanMarvin added the question ❓ Further information is requested label Nov 8, 2023
@tpsteiner
Copy link
Author

Hi @JanMarvin thanks for the quick response. I feel dumb for not checking the issues list more thoroughly.
That issue seems to be solved on the dev branch.

devtools::install_github("JanMarvin/openxlsx2")

@JanMarvin
Copy link
Owner

No worries, thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question ❓ Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants