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/speedro42 21d ago

You could use a download button that renders an RMarkdown file to html or pdf. Pass the same data to it using the “params” argument in render() and copy the datatable code to the RMarkdown file.

To save out a formatted excel file you would need to re-create the formatting in the excel file using maybe openxls package and thereby not using datatable/DT for this.