Remove a column from a workbook #556
JanMarvin
started this conversation in
Show and tell
Replies: 1 comment
-
Similar approach demonstrating the use of ## create file
dat <- data.frame(
AA = 1:4,
BBB = 2:5,
VVV = 6:9
)
library(openxlsx2)
wb <- wb_workbook()$add_worksheet()$add_data(x = dat)
wb$add_fill(dims = "A1:C5", color = wb_color("yellow"))
wb$add_fill(dims = "A2:A3", color = wb_color("red"))
wb$add_fill(dims = "A5", color = wb_color("lightgray"))
wb$add_fill(dims = "C4", color = wb_color("lightgray"))
wb$add_fill(dims = "B2;B4", color = wb_color("lightblue"))
###
wb_to_df(wb)
#> AA BBB VVV
#> 2 1 2 6
#> 3 2 3 7
#> 4 3 4 8
#> 5 4 5 9
left_dat <- wb_data(wb, dims = "A1:A5", colNames = FALSE)
right_dat <- wb_data(wb, dims = "C1:C5", colNames = FALSE)
wb$add_worksheet()
wb$copy_cells(data = left_dat, dims = "A1")
wb$copy_cells(data = right_dat, dims = "B1")
# wb$open() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In this SO I demonstrate how to remove a column from a workbook. I do not recommend this in any way, it is nasty and does not handle all the many cases that can break along the way. Anyhow, sometimes nasty solutions are all we have.
We start with a workbook containing the data frame below and some styles:
Now we want to remove column B (the BBB column in the data)
Voila, we are done.
Beta Was this translation helpful? Give feedback.
All reactions