-
Notifications
You must be signed in to change notification settings - Fork 11
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
[dims] extend wb_dims() to accept multiple columns #1019
Conversation
Related issue: #796 (comment) |
This comment was marked as resolved.
This comment was marked as resolved.
Sure, take your time. I've adjusted the |
b79e3a1
to
e4de9f2
Compare
I may not have time to review before end of week.. |
No worries, it’s not time critical. |
e4de9f2
to
e0976d3
Compare
Achievement unlocked! Make it even more confusing 😄 library(openxlsx2)
d_full <- wb_dims(x = mtcars)
d_col <- wb_dims(x = mtcars, cols = c(2))
d_cols <- wb_dims(x = mtcars, cols = c(2, 4))
d_row <- wb_dims(x = mtcars, rows = c(4))
d_rows <- wb_dims(x = mtcars, rows = c(2, 4:5))
d_cols_rows <- wb_dims(x = mtcars, cols = c(2, 4), rows = c(2, 4:5))
wb <- wb_workbook()$
add_worksheet()$add_data(x = mtcars)$add_fill(dims = d_full, color = wb_color("green"))$
add_worksheet()$add_data(x = mtcars)$add_fill(dims = d_col, color = wb_color("green"))$
add_worksheet()$add_data(x = mtcars)$add_fill(dims = d_cols, color = wb_color("green"))$
add_worksheet()$add_data(x = mtcars)$add_fill(dims = d_row, color = wb_color("green"))$
add_worksheet()$add_data(x = mtcars)$add_fill(dims = d_rows, color = wb_color("green"))$
add_worksheet()$add_data(x = mtcars)$add_fill(dims = d_cols_rows, color = wb_color("green"))
if (interactive()) wb$open() |
b7ad648
to
d6ce1f9
Compare
d6ce1f9
to
e5cd66e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to have kept you waiting! I think this is a nice improvement. You were able to simplify the code from the previous time I looked at this?
I guess that a good way to test this would be to see if this works with various functions.
,
will work with wb_add_conditional_formatting()
, data?
I think it is worth publicizing this elsewhere in docs (in a follow-up perhaps?)
Thankfully, I didn't have to work with Excel a lot lately ;).
Maybe we can ask user testing too at this point? I remember this issue in particular that would be solved with this
if (all(diff(rows_arg) == 1L)) | ||
frow <- frow + min(rows_arg) - 1L | ||
else | ||
frow <- vapply(rows_arg, function(x) frow + min(x) - 1L, NA_real_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
frow <- vapply(rows_arg, function(x) frow + min(x) - 1L, NA_real_) | |
frow <- vapply(rows_arg, function(x) frow + min(x) - 1L, NA_real_) |
After merge, I will install this version so I can do a bit of integration testing before next release! |
We have all the time in the world! But the code is not really simplified. I only fixed what I broke with non consecutive rows. And I'm not really hyped on the coding in this PR 😅
Haven't checked this. Chances are it wont work. Afaik conditional formatting requires a consecutive range, but haven't tried.
Yeah, that's a luxury I don't have in my life ... at least with
With open source development everyone wants working releases and nobody wants to test. Same reason R-Core has to do many patch releases ... |
Alright, merging this one. After all we can always revert and at least our tests don't bark at us |
Fix #843
This PR extends
wb_dims()
to accept multiple columns: