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

Styles functions to accept logical and numeric #557

Closed
JanMarvin opened this issue Mar 12, 2023 · 0 comments · Fixed by #558
Closed

Styles functions to accept logical and numeric #557

JanMarvin opened this issue Mar 12, 2023 · 0 comments · Fixed by #558
Labels
enhancement 😀 New feature or request

Comments

@JanMarvin
Copy link
Owner

At the moment we only accept characters in cases where logicals or numerics would feel more natural to users.

Using a wb_add_font() example:

library(openxlsx2)
wb <- wb_workbook() %>% wb_add_worksheet("S1") %>% wb_add_data("S1", mtcars)

# This works and is documented
wb <- wb %>% wb_add_font("S1", "A1:K1", name = "Arial", bold = "1", size = "14")

# This should work too
wb <- wb %>% wb_add_font("S1", "A2:K2", name = "Arial", bold = TRUE, size = 14)
#> Error in eval(expr, envir, enclos): Expecting a string vector: [type=NULL; required=STRSXP].

We have to identify cases where logicals and numerics can be used as substitutes and wrap the content if not character and not NULL.

@JanMarvin JanMarvin added the enhancement 😀 New feature or request label Mar 12, 2023
@JanMarvin JanMarvin linked a pull request Mar 12, 2023 that will close this issue
2 tasks
JanMarvin added a commit that referenced this issue Mar 13, 2023
* use as_xml_attr() in wb_styles functions

* do not create empty xml arguments

* fix tests

* Revert "fix tests"

This reverts commit 45d5e63.

* add remove_empty_attr argument to xml_attr_mod() and restore behavior

* update NEWS

* add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 😀 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant