Skip to content

Commit

Permalink
[add_clone_worksheet] fix comments. closes #658
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Jun 22, 2023
1 parent 785e41a commit 7266426
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ wbWorkbook <- R6::R6Class(
}

if (length(cmt_id)) {
self$append("comments", self$comments[[cmt_id]])
self$append("comments", self$comments[cmt_id])
self$worksheets[[old]]$relships$comments <- length(self$comments)
}

Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-cloneWorksheet.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,17 @@ test_that("copy cells", {
expect_equal(unlist(t(dat)), unlist(got), ignore_attr = TRUE)

})

test_that("cloning comments works", {

tmp <- temp_xlsx()

c1 <- create_comment(text = "this is a comment", author = "")

# cloning comments from loaded worksheet did not work
wb <- wb_workbook()$add_worksheet()$add_comment(dims = "A1", comment = c1)$save(tmp)
wb <- wb_load(tmp)$clone_worksheet()

expect_equal(wb$comments[[1]][[1]]$ref, wb$comments[[2]][[1]]$ref)

})

0 comments on commit 7266426

Please sign in to comment.