R/dt_buttons_options.R

Defines functions dt_buttons_options

Documented in dt_buttons_options

#' options for DT buttons
#'
#' @param filename function that returns the filename for the downloaded file
#' @param cols columns to download.  Passed to exportOptions
#'
dt_buttons_options <- function(
  filename = function() paste0("file-", Sys.Date(), ".xlsx"),
  cols = NULL
) {

  out <- list(
    list(
      extend = "excel",
      text = "Download",
      title = paste0("golf_carts-", Sys.Date())
    )
  )

  if (!is.null(cols)) {
    out[[1]][[1]]$exportOptions <- list(
      columns = cols
    )
  }

  out
}
Tychobra/tychobratools documentation built on April 12, 2022, 12:29 a.m.