You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to clone some styles across workbooks and came across two issues.
One was some stoi error (have seen this in a previous issue) if I was applying more styles than I had rows in my data. not sure why, was not able to reproduce this locally.
The style I wanted to clone was trickier to apply to a range of cells.
library(openxlsx2)
# some formatted input sheetwb_style<- wb_workbook()$add_worksheet("tab")$
add_fill(dims="A1:A5", color= wb_color("yellow"))$
add_fill(dims="A6:A10", color= wb_color("orange"))
# the workbook where I want to apply the styling from the previous workbookwb<- wb_workbook()$add_worksheet("dat")$add_data(x= head(mtcars, 10))
# clone the entire worksheet. maybe wb_clone_sheet_style() can use a workbook as well?wb$clone_worksheet(old="tab", new="tab", from=wb_style)
# # to long styles caused "Error: stoi" issues on Windows# styles <- wb$get_cell_style(sheet = "tab", dims = "A1:A11")styles<-wb$get_cell_style(sheet="tab", dims="A1:A10")
# remove the sheet, I only need the stylewb$remove_worksheet("tab")
# # broken. the styles are all over the place# wb$set_cell_style(sheet = "dat", dims = "A1:D10", style = styles)# works, but looks a bit complexwb$set_cell_style(
sheet="dat",
dims="A1:D10",
style= unclass(t(matrix(styles, nrow= length(styles), ncol=4)))
)
if (interactive()) wb$open()
The text was updated successfully, but these errors were encountered:
I wanted to clone some styles across workbooks and came across two issues.
The text was updated successfully, but these errors were encountered: