wb_dims: Error in wb_dims(rows = 2:(nrow(data_in) + 1), cols = sel_columns) : You must supply positive, consecutive values to cols
#844
-
Hello!
When I try:
the error is:
As my simple workaround, I can loop across all elements and apply conditional_formating as many times as needed:
But I am wondering if am I just missing something and that option is already implemented? openxlsx2 version 1.1 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Hi, indeed, your workaround is correct. By disallowing non-consecutive columns, we wanted to avoid that it would not simply apply the conditional formatting to everything. See #796 (comment) Because Another syntax to do this would be # wb_dims can understand what you want to do if you provide `x`, the data.
# It will perform operations based on that
# to operate on column i, only for the data, the following code is equivalent to the one your provided.
for (i in sel_columns){
wb$add_conditional_formatting(my_var, dims = wb_dims(x = data_in, cols = i),
rule = ">=2", style = "negative")
} |
Beta Was this translation helpful? Give feedback.
-
Ok,
Those empty cells are also colored.
So, I was wondering if I could apply a Thanks again! |
Beta Was this translation helpful? Give feedback.
Ok,
I get the potential problem. Using the occasion, I would like to ask about the
rule
inadd_conditional_formatting()
My wb is created based on dataframe, which has NAs, and so I do not want #N/A in my workbook.
wb$add_data(my_var, data_in, na.strings = NULL)
When I apply a different rule:
Those empty cells are also colored.
I know I can add yet
add_conditional_formatting
like:So, I was wondering if I could apply a
rule
with a condition within? Or maybe I…