Skip to content

Commit

Permalink
[pt] use multiple selection per default
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Nov 23, 2023
1 parent 89dd16f commit f55d7e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions R/class-workbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,12 @@ wbWorkbook <- R6::R6Class(
if (missing(pivot_table)) pivot_table <- NULL
if (missing(params)) params <- NULL

if_not_missing <- function(x) if (missing(x)) NULL else as.character(x)

if (any(duplicated(c(if_not_missing(filter), if_not_missing(rows), if_not_missing(cols))))) {
stop("duplicated variable in filter, rows, and cols detected.")
}

if (!missing(fun) && !missing(data)) {
if (length(fun) < length(data)) {
fun <- rep(fun[1], length(data))
Expand Down
17 changes: 9 additions & 8 deletions R/helper-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -827,8 +827,8 @@ create_pivot_table <- function(
if (!abs(sort) %in% seq_along(rows_pos))
warning("invalid sort position found")

if (!abs(sort) == match(i, rows_pos))
sort <- NULL
if (!abs(sort) == match(i, rows_pos))
sort <- NULL
}
}

Expand All @@ -840,8 +840,8 @@ create_pivot_table <- function(
if (!abs(sort) %in% seq_along(cols_pos))
warning("invalid sort position found")

if (!abs(sort) == match(i, cols_pos))
sort <- NULL
if (!abs(sort) == match(i, cols_pos))
sort <- NULL
}
}

Expand All @@ -864,18 +864,19 @@ create_pivot_table <- function(
else sort <- "ascending"
}

sort_item <- params$sort_item
choose <- params$choose
multi <- if (is.null(choose)) NULL else as_xml_attr(TRUE)

attrs <- c(
axis, dataField, showAll = "0", sortType = sort,
axis, dataField, showAll = "0", multipleItemSelectionAllowed = multi, sortType = sort,
compact = as_xml_attr(compact), outline = as_xml_attr(outline)
)

tmp <- xml_node_create(
"pivotField",
xml_attributes = attrs)

sort_item <- params$sort_item
choose <- params$choose

if (i %in% c(filter_pos, rows_pos, cols_pos)) {
nms <- names(x[i])
sort_itm <- sort_item[[nms]]
Expand Down

0 comments on commit f55d7e2

Please sign in to comment.