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

[clean] The wrapper wb_clean_sheet() gained a new argument hyperlinks #1140

Merged
merged 1 commit into from
Sep 20, 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: 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.

Loading