尝试下载Shiny中的工作簿

问题描述

我试图使用户将两个不同的选项卡下载到工作簿中。下面的代码打开下载窗口,但它不会保存excel文件,而是只能选择一个txt文件为空。起初它用来给出一个错误,但是现在它只是空白。有什么帮助吗?如果我用c(1:100)来完成工作簿部分,则效果很好。

 output$downloadData <- downloadHandler(
 
  filename = function()
      {
    if(input$hub_name == 'ES'){
      
    #will fix this with the local date and year I develop.
    paste("easterseals_Bump_August2020",".xlsx",sep = '')
      
    }else if (input$hub_name == 'UPO'){
      
      #will fix this with the local date and year I develop.
     paste("UPO_Bump_August2020",sep = '')
    }
  },content = function(file) {
    # Creating a workbook for user to download
    wb <- createWorkbook(type = 'xlsx')
    
    #create the workbook for the different sheet.
    sheet.1 <- createSheet(wb,sheetName = "Review")
    sheet.2 <- createSheet(wb,sheetName = "Non-Review")
    
    rev <- review()
    non.rev <- non_review()

    #writing the data to the different sheet.
    addDataFrame(rev,sheet=sheet.1,startRow=1,startColumn=1,row.names=TRUE)
    
    addDataFrame(non.rev,sheet=sheet.2,row.names=TRUE)
    
    #saving workbook
    if(input$hub_name == 'ES'){
      
      #will fix this with the local date and year I develop.
      saveWorkbook(wb,paste("easterseals_Bump_August2020",sep = ''))
      
    }else if (input$hub_name == 'UPO'){
      
      #will fix this with the local date and year I develop.
      saveWorkbook(wb,paste("UPO_Bump_August2020",sep = ''))
    }
    


  })

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)