Add formulas to row #973
Unanswered
vladimirovnikita
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @vladimirovnikita , currently positioning formulas with For the time being you can use the following. This constructs a data frame with a formula class that contains the formula that you want to write. A second approach would be to loop over the cells with formulas that you want to write and place them with library(openxlsx2)
packageVersion("openxlsx2")
#> [1] '1.4'
wb <- wb_workbook()
wb$add_worksheet()
wb$add_data(x=data.frame(
`A`=c(1,2),
`B`=c(3,4),
`C`=c(5,6)),
col_names = FALSE)
# formula data frame that can be used to write formulas row wise
fml <- data.frame(
sumA = "A1*A2",
sumB = "B1*B2",
sumC = "C1*C2"
)
class(fml$sumA) <- c("formula", "character")
class(fml$sumB) <- c("formula", "character")
class(fml$sumC) <- c("formula", "character")
wb$add_data(x = fml, dims = "A3:C3", col_names = FALSE)
if (interactive()) wb$open() |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
Please tell me how to add formulas to a row?
The code below does not do what I expect and inserts formulas into column "A"
Beta Was this translation helpful? Give feedback.
All reactions