Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[write] share formulas without A1 cell reference #1223

Merged
merged 2 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading