JanMarvin / openxlsx2

openxlsx2 - read, write and modify xlsx files
https://janmarvin.github.io/openxlsx2/
Other
117 stars 9 forks source link

[wb_to_df] create type `f` when reading formula #1103

Closed JanMarvin closed 1 month ago

JanMarvin commented 1 month ago
library(openxlsx2)

# create example data
df <- data.frame(
  x = 1:3, y = 1:3,
  z = paste(paste0("A", 1:3 + 1L), paste0("B", 1:3 + 1L), sep = "+"),
  stringsAsFactors = FALSE
)
class(df$z) <- c(class(df$z), "formula")

# create workbook
wb <- wb_workbook()$
  add_worksheet()$
  add_data(x = df)

# read sheet 1
x <- wb_to_df(wb, show_formula = TRUE)

# write sheet 2
wb$add_worksheet()$
  add_data(x = x)

if (interactive()) wb$open()