你好,

我很新闪亮的应用程序。当我选择我的数据从excel文件,我想选择表,并在应用程序上显示它。
我使用reactive在SelectInput上显示和选择数据表的名称,但当我更改选择表时,它显示为1s并返回到第一个表。我的代码有什么问题?
谢谢你!

library(shiny) library(readxl) ui <- fluidPage(fileInput('file1', 'Input'), selectInput('sheet', 'Afficher sheet', ""), tableOutput('table')) server <- function(Input, output, session) {data <- reactive({req(Input $file1) ## ?req # require that Input is available inFile <- Input $file1 updateSelectInput(session, inputId = 'sheet', choices = excel_sheets(inFile$datapath)) my_data <- read_excel(inFile$datapath,返回(my_data)})输出$table <- renderTable({data()})} shinyApp(ui, server)

欢迎加入社区@Helene_Fr!试着拉updateSelectInput从反应物中取出,放入observeEvent触发输入file1美元.我相信这将产生所需的功能。

server <- function(input, output, session) {data = reactive({req(input$file1) read_excel(input$file1$datapath, sheet = input$sheet)}) observeEvent(input$file1, {updateSelectInput(session, inputId = 'sheet', choices = excel_sheets(input$file1$datapath))}) output$table <- renderTable({data()})}
1像

效果很好,谢谢!

1像

该主题在最后一次回复后7天自动关闭。不再允许新的回复。

如果您有一个与之相关的查询或其中一个回复,请开始一个新的主题并使用链接返回。