The toy shiny app in the code below renders a table from the R excelR package. The table data has been manufactured from 2 calls to the mtcars data to force it to have many columns so that it extends beyond the modal that presents it, and is wrapped in a div with an x-scrolbar so that all the columns can be viewed with horizontal scrolling (commented out as doesn’t achieve the goal).
Scrolling the columns this way though also moves the pagination buttons.
I am looking to find out 2 things please
- how to horizontal scroll the table only.
- and how to freeze the first 3 columns so that they are fixed in place and not part of the scroll.
Anyone know how to achieve this please? I cannot see any functionality at the package documentation.
I have also tried various combinations of autoFill and autoWidth opined at https://github.com/Swechhya/excelR/issues/57
library(shiny)
library(excelR)
library(dplyr)
library(tibble)
ui <- fluidPage(
column(12, actionButton('btn_modal', 'modal up')))
server <- function(input, output) {
observeEvent(input$btn_modal,{
showModal(modalDialog(
# tags$div(style = 'overflow-x: scroll;',
excelOutput('duplicator_table', width = '100%', height = '500px')
# )
))
})
output$duplicator_table <- renderExcel({
data_2 <- data_1 <- mtcars
data_1 <- forecast_data_1 %>% rownames_to_column('car_models')
colnames(forecast_data_2) <- paste0(colnames(forecast_data_2), '_2')
rownames(forecast_data_2) <- NULL
data_3 <- data_1 %>% bind_cols(data_2)
excelTable(
data = data_3,
pagination = 15
)
})
}
shinyApp(ui = ui, server = server)