Angelo
Angelo

Reputation: 1785

R shiny datatable extension "Buttons" - how to export the whole table to excel?

I have an R Shiny app and one of the output elements is a databale. I use the following code to display Buttons like Copy, Excel, Print:

df <- datatable(df, 
                  rownames= FALSE,
                  filter = 'top',
                  extensions = 'Buttons', 
                  options = list(scrollX = TRUE
                                 , pageLength = 5
                                 , dom = 'Blfrtip'
                                 ,buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
                                 )) 

The table has about 2000 rows. Everything works great, but if I click on CSV it only exports the rows visualized on the screen. Is there anything that could be done to make this CSV button exporting all the data in Excel? Many thanks

Upvotes: 7

Views: 3342

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84679

Set server = FALSE in the renderDT function:

output[["zzz"]] <- renderDT({
  datatable(......)
}, server = FALSE)

Upvotes: 6

Related Questions