I created a module to help me accept 1)an excel file 2)a text input for the sheet name and 3) a text input for the range.
I want to be able to use this module in an App such that each time I click on the action button (AddExcelDataButton in the code below), it allows me to input a different file. I also need to be able to extract the contents of the file later.
I tried the below code in the main App, but it is throwing me the following errors error1: The UI is linking all the inputs "inside the button" error2: I am unable to figure out how to "access" or retrieve the filenames later in the code.
Any help in doing this the right way is highly appreciated please!
CODE FOR THE MODULE:
importExceldataUI <- function(importExceldata){
tagList(
tags$div(
HTML(paste0("<b>", "Enter Your Data Here"))
),
tags$div(
fileInput(inputId = "ImportExcelFile",
label = "Excel File",
multiple=FALSE),
style = "display:inline-block; vertical-align:top"
),# end of tags$div for fileInput ImportExcelFile
tags$div(
textInput(inputId = "ExcelSheetName",
label = "Sheet",
value="Data",),
style = "display:inline-block; vertical-align:top"
),#end of tags$Div for texinput-ExcelSheetName
tags$div(
textInput(inputId = "ExcelSheetRange",
label = "Range",
value = "C5:BN1000"),
style = "display:inline-block"
)#end of tags$div for textInput - sheetrange
)
}
importExceldataServer <- function(importExceldata){
moduleServer(importExceldata, function(input, output, session){
})
}
CODE FOR MAIN APP
importExceldataApp <- function(){
ui <- fluidPage(
mainPanel(
actionButton(inputId = "AddExcelDataButton", label = "Click here to add Excel Data"),
)#emd pf mainpanel
)
server <- function(input, output, session){
observeEvent(input$AddExcelDataButton, {
insertUI(selector = "#AddExcelDataButton",
ui = importExceldataUI(paste0("file",input$AddExcelDataButton)))
})#end of observeEvent
}
shinyApp(ui, server)
}
importExceldataApp()