Skip to content

Commit

Permalink
[write] share formulas without A1 cell reference (#1223)
Browse files Browse the repository at this point in the history
* [misc] begin new development

* [write] allow shared formulas without A1 cell reference
  • Loading branch information
JanMarvin authored Dec 23, 2024
1 parent ee4758a commit 3d4ce6e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: openxlsx2
Title: Read, Write and Edit 'xlsx' Files
Version: 1.12
Version: 1.12.0.9000
Language: en-US
Authors@R: c(
person("Jordan Mark", "Barbone", email = "[email protected]", role = "aut", comment = c(ORCID = "0000-0001-9788-3628")),
Expand Down
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 3d4ce6e

Please sign in to comment.