Skip to content

Commit

Permalink
[write] allow shared formulas without A1 cell reference
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Dec 23, 2024
1 parent 832f0bc commit 9fb85d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# openxlsx2 (development version)

## Fixes

* Formulas that do not have a `A1` cell reference to increase, are now shareable too. `wb_add_formula(x = "1", dims = "A1:A2", shared = TRUE)`


***************************************************************************

# openxlsx2 1.12

## New features
Expand Down
2 changes: 1 addition & 1 deletion R/write.R
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ write_data2 <- function(
cc$f_t <- "shared"
cc[1, "f_ref"] <- dims
cc[2:nrow(cc), "f"] <- ""
cc$f_si <- max(int_si) + 1L
cc$f_si <- max(int_si, -1L) + 1L
}

if (is.null(wb$worksheets[[sheetno]]$sheet_data$cc)) {
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-formulas.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,13 @@ test_that("writing shared formulas works", {
got <- unique(cc$f_si)
expect_equal(exp, got)

wb <- wb_workbook()$add_worksheet()
wb$add_formula(x = "1", dims = "A1:B1", shared = TRUE)

exp <- "shared"
got <- unique(wb$worksheets[[1]]$sheet_data$cc$f_t)
expect_equal(exp, got)

})

test_that("increase formula dims if required", {
Expand Down

0 comments on commit 9fb85d9

Please sign in to comment.