This is a wrapper around the DT::datatable() function that adds buttons for exporting the table to CSV, Excel, and PDF, as well as a print button. It also enables scrolling and fixed columns by default.
Usage
table_dt(
data,
fn = "datatable",
buttons = list(list(extend = "csv", filename = fn), list(extend = "excel", filename =
fn), list(extend = "pdf", filename = fn, orientation = "landscape", customize =
DT::JS("function(doc) {", " doc.defaultStyle.fontSize = 5;", "}")), "print"),
scroller = TRUE,
scrollY = JS("window.innerHeight * 0.7 + 'px'"),
scrollX = TRUE,
fixedColumns = list(leftColumns = 4),
escape = FALSE,
...
)
Arguments
- data
The data to be displayed in the DataTable
- fn
The filename to be used for the exported files when using the default button definition
- buttons
A list of buttons to be displayed in the DataTable
- scroller
Logical value indicating whether to enable scrolling in the DataTable
- scrollY
JavaScript code to set the height of the DataTable
- scrollX
Logical value indicating whether to enable horizontal scrolling in the DataTable
- fixedColumns
A list specifying the number of fixed columns in the DataTable
- escape
Logical value indicating whether to escape HTML entities in the DataTable
- ...
Additional options to be passed to the DT::datatable function