3
votes

In my shiny app, I'm using:

# server.R
  output$out_table = DT::renderDataTable(
    func_to_creat_dataframe(),
    rownames= FALSE,
    extensions = c('Buttons'),
    options = list(
      pageLength = 96,
      lengthMenu = c(96, 384, 1536),
      dom = 'Blfrtip',
      buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
    )
  )
# UI.R
DT::dataTableOutput('out_table')

...and when I use the "Excel" button to export the table, the exported table has a "title" row directly above the header row. This title row consists of one merged cell that spans across the entire header. How do I remove this? This title row interferes with downstream processing of the file, and it's completely unnecessary, so I don't see why it appears to be default for the datatable file export buttons.

1

1 Answers

3
votes

Try that:

DT::datatable(
  iris,
  rownames= FALSE,
  extensions = c('Buttons'),
  options = list(
    pageLength = 96,
    lengthMenu = c(96, 384, 1536),
    dom = 'Blfrtip',
    buttons = list(
      'copy', 
      'csv', 
      list(extend = 'excel', title = NULL), 
      'pdf', 
      'print'
    )
  )
)