Skip to content

Commit

Permalink
[clean] The wrapper wb_clean_sheet() gained a new argument `hyperli…
Browse files Browse the repository at this point in the history
…nks`
  • Loading branch information
JanMarvin committed Sep 20, 2024
1 parent 93a7a99 commit 53d9f4a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

* Add `address` field to `wb_add_image()`. This can be used to add a url or mailto address to an image ([1138](https://github.com/JanMarvin/openxlsx2/pull/1138), conversion from a PR by @jistria for `openxlsx`)

* It is now possible to remove hyperlinks with either `wb_remove_hyperlinks()` or `wb_clean_sheet()`. [1139](https://github.com/JanMarvin/openxlsx2/pull/1139)

## Fixes

* The integration of the shared formula feature in the previous release broke the silent extension of dims, if a single cell `dims` was provided for an `x` that was larger than a single cell in `wb_add_formula()`. [1131](https://github.com/JanMarvin/openxlsx2/pull/1131)
Expand Down
7 changes: 5 additions & 2 deletions R/class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -3015,6 +3015,7 @@ wb_add_chart_xml <- function(
#' @param characters remove all characters
#' @param styles remove all styles
#' @param merged_cells remove all merged_cells
#' @param hyperlinks remove all hyperlinks
#' @return A Workbook object
#' @export
wb_clean_sheet <- function(
Expand All @@ -3024,7 +3025,8 @@ wb_clean_sheet <- function(
numbers = TRUE,
characters = TRUE,
styles = TRUE,
merged_cells = TRUE
merged_cells = TRUE,
hyperlinks = TRUE
) {
assert_workbook(wb)
wb$clone(deep = TRUE)$clean_sheet(
Expand All @@ -3033,7 +3035,8 @@ wb_clean_sheet <- function(
numbers = numbers,
characters = characters,
styles = styles,
merged_cells = merged_cells
merged_cells = merged_cells,
hyperlinks = hyperlinks
)
}

Expand Down
6 changes: 4 additions & 2 deletions R/class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -7909,14 +7909,16 @@ wbWorkbook <- R6::R6Class(
#' @param characters remove all characters
#' @param styles remove all styles
#' @param merged_cells remove all merged_cells
#' @param hyperlinks remove all hyperlinks
#' @return The `wbWorksheetObject`, invisibly
clean_sheet = function(
sheet = current_sheet(),
dims = NULL,
numbers = TRUE,
characters = TRUE,
styles = TRUE,
merged_cells = TRUE
merged_cells = TRUE,
hyperlinks = TRUE
) {
sheet <- private$get_sheet_index(sheet)
self$worksheets[[sheet]]$clean_sheet(
Expand All @@ -7927,7 +7929,7 @@ wbWorkbook <- R6::R6Class(
merged_cells = merged_cells
)

if (numbers || characters)
if (hyperlinks)
self$remove_hyperlink(
sheet = sheet,
dims = dims
Expand Down
5 changes: 4 additions & 1 deletion man/wbWorkbook.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/wb_clean_sheet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53d9f4a

Please sign in to comment.