Skip to content

Commit 972ea14

Browse files
committed
cleanup
1 parent f865f26 commit 972ea14

5 files changed

+14
-10
lines changed

R/class-workbook-wrappers.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,7 @@ wb_get_tables <- function(wb, sheet = current_sheet()) {
18911891
#' @param wb A workbook object
18921892
#' @param sheet A name or index of a worksheet
18931893
#' @param table Name of table to remove. See [wb_get_tables()]
1894+
#' @param remove_data Removes the data as well
18941895
#' @return character vector of table names on the specified sheet
18951896
#' @examples
18961897
#'
@@ -1915,9 +1916,9 @@ wb_get_tables <- function(wb, sheet = current_sheet()) {
19151916
#' wb$remove_tables(sheet = 1, table = "iris")
19161917
#' wb$add_data_table(sheet = 1, x = iris, tableName = "iris", startCol = 1)
19171918
#' @export
1918-
wb_remove_tables <- function(wb, sheet = current_sheet(), table) {
1919+
wb_remove_tables <- function(wb, sheet = current_sheet(), table, remove_data = TRUE) {
19191920
assert_workbook(wb)
1920-
wb$clone()$remove_tables(sheet = sheet, table = table)
1921+
wb$clone()$remove_tables(sheet = sheet, table = table, remove_data = remove_data)
19211922
}
19221923

19231924

R/class-workbook.R

+5-2
Original file line numberDiff line numberDiff line change
@@ -5027,8 +5027,9 @@ wbWorkbook <- R6::R6Class(
50275027
#' @description remove tables
50285028
#' @param sheet sheet
50295029
#' @param table table
5030+
#' @param remove_data removes the data as well
50305031
#' @returns The `wbWorkbook` object
5031-
remove_tables = function(sheet = current_sheet(), table) {
5032+
remove_tables = function(sheet = current_sheet(), table, remove_data = TRUE) {
50325033
if (length(table) != 1) {
50335034
stop("table argument must be length 1")
50345035
}
@@ -5066,7 +5067,9 @@ wbWorkbook <- R6::R6Class(
50665067
attr(self$worksheets[[sheet]]$tableParts, "tableName") <- worksheet_table_names[-to_remove]
50675068

50685069
## now delete data
5069-
# self$clean_sheet(sheet = sheet, dims = refs)
5070+
if (remove_data)
5071+
self$clean_sheet(sheet = sheet, dims = refs)
5072+
50705073
invisible(self)
50715074
},
50725075

R/get-named-regions.R

-4
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,5 @@ wb_get_named_regions <- function(x, tables = FALSE) {
127127

128128
}
129129

130-
if (NROW(z) == 0) {
131-
z <- NULL
132-
}
133-
134130
z
135131
}

man/wbWorkbook.Rd

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/wb_remove_tables.Rd

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)