Skip to content

Conversation

JanMarvin
Copy link
Owner

This allows the following, came across this in the following SO. The issue at hand is that the first evaluation sets the current_sheet() no matter what the actual current sheet is.

I was considering updating the waiver code to add an argument or something similar, but there are not that many functions that take two potential sheets (clone worksheet and the one fixed here)

library(openxlsx2)

df <- data.frame(
  Date = Sys.Date() - 0:4, 
  Logical = c(TRUE, FALSE, TRUE, TRUE, FALSE),
  Currency = paste("$", -2:2),
  Accounting = -2:2,
  hLink = "https://CRAN.R-project.org/",
  Percentage = seq(-1, 1, length.out = 5), 
  TinyNumber = runif(5)/1e+09,
  stringsAsFactors = FALSE
)

dat_grouped <- df %>% dplyr::group_by(Date)

wb <- wb_workbook()$
  # first worksheet
  add_worksheet("1st")$
  add_data_table(x = dat_grouped, 
                 table_style = "TableStyleLight13")$
  set_col_widths(cols = "A:G", widths = c(10, 10, 10, 10, 25, 10, 10))$
  # second worksheet
  add_worksheet("2nd")$
  add_data_table(x = dat_grouped, 
                 table_style = "TableStyleLight13")$
  clone_sheet_style(from = "1st", to = openxlsx2::current_sheet())
  
if (interactive()) wb$open()

@JanMarvin JanMarvin changed the title allow from or to to be waivers [styles] allow from and to to be waivers Oct 1, 2023
@JanMarvin JanMarvin mentioned this pull request Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant