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
Cell text with <br/> is replaced with NA #894
Labels
bug 🐛
Something isn't working
Comments
Same thing happens with any closing HTML tag:
|
Hi @dhicks, thanks for the report. Indeed a tricky one. The xml cell needs to be escaped like this: "<is><t>foo <em>bar</em></t></is>" But since we detect something like an xml tag inside, we assume that there the cell is already escaped. openxlsx2:::txt_to_is('foo <em>bar</em>')
#> "<is><em>bar</em></is>" Fixing this is a bit of a nuisance: library(openxlsx2)
bar <- data.frame(
x = xml_node_create(
xml_name = "t",
xml_children = openxlsx2:::replace_legal_chars("foo <em>bar</em>")
)
)
wb <- wb_workbook() |>
wb_add_worksheet() |>
wb_add_data_table(x = bar)
wb$to_df()
#> x
#> 2 foo <em>bar</em>
if (interactive()) wb$open() Same for the first example: library(openxlsx2)
bar <- data.frame(
x = xml_node_create(
xml_name = "t",
xml_children = openxlsx2:::replace_legal_chars("foo <br/> bar")
)
)
wb <- wb_workbook() |>
wb_add_worksheet() |>
wb_add_data_table(x = bar)
wb$to_df()
#> x
#> 2 foo <br/> bar
if (interactive()) wb$open() |
Interestingly my solution in is part of library(openxlsx2)
wb <- wb_workbook()$add_worksheet()$add_data(
x = fmt_txt("a <br/> b")
)
wb$to_df()
#> x
#> 2 a <br/> b |
JanMarvin
added a commit
that referenced
this issue
Jan 16, 2024
JanMarvin
added a commit
that referenced
this issue
Jan 17, 2024
JanMarvin
added a commit
that referenced
this issue
Jan 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: