I have a shiny dashboard where the tables are created with the reactable
package. I have simple and nested tables and as far as I can see, there is only a download option for csv:
library(htmltools)
library(fontawesome)
data <- MASS::Cars93[1:15, c("Manufacturer", "Model", "Type", "Price")]
htmltools::browsable(
tagList(
tags$button(
tagList(fontawesome::fa("download"), "Download as CSV"),
onclick = "Reactable.downloadDataCSV('cars-download-table', 'cars.csv')"
),
reactable(
data,
searchable = TRUE,
defaultPageSize = 5,
elementId = "cars-download-table"
)
)
)
I want to create one Excel download file with the following attributes:
- the tables to download are selected via a
checkboxGroupInput
- one Excel sheet per selected item
- the name of the sheet corresponds to selected item
- if there is more than one table in the selected item, all those tables should be in one sheet (divided by some empty rows)
- some captions (read from another file) should be inserted above the tables
The problem is, that I want to use the data shown in the reactable
(e.g. the selected columns), therefore I can not use the raw data. Is there some kind of package I can use?
So far, I only have a slow solution where I put the reactable
into an additional variable before I render the table and then I read the data from this variable and use the package openxlsx
to write the Excel.