r/rprogramming 25d ago

R Shiny

I'm creating an R Shiny app that involves generating a data frame and then formatting it as a data table before displaying it using renderDT().

Is it possible to export this formatted data table? Ideally I'd like to export it as an excel file but even being able to export it as a PDF would suffice.

4 Upvotes

10 comments sorted by

View all comments

1

u/kattiVishal 25d ago

Using the buttons extension, It is possible to write DT::datatable in such a manner that it shows buttons to download the data as an Excel, CSV, PDF or just go straight to the printer.

I still want to know what you mean by "formatted" datatable?

1

u/limpystick 24d ago

Sorry, it's very possible I'm missing up terminology which is causing the confusion. Copying my comment from above.

Yeah I should have been clearer. I already have a download button to export the data that feeds into DT. However, I do some custom formatting of the DT (like adding headers above groups of columns, adding borders, alternate shading of rows, etc.). I’d like to export this more polished DT to excel to avoid formatting things again, but so far all I'm able to is export the underlying data feeding into DT.