title: Download multiple csv files with one button (downloadhandler) with R Shiny
body: <p>*Hi, I'm trying to download multiple csv file from a unique excel file. I want to download (using only one downloadbutton) the differents sheets from the excel file.
  I don't understand why a for() loop doesn't work, and I can't see how can I do? 
  If anyone knows..</p>
  
  <p>The point is to download differents csv files, which are in the "wb" list (wb[1],wb[2]...)
  Thanks.
  Here is my code who works with the third sheet for instance (and sorry for my bad english) :
  ui :</p>
  
  <pre><code>library(readxl)
  library(shiny)
  library(XLConnect)
  fluidPage(
  titlePanel("Export onglets en CSV"),
    sidebarLayout(
      sidebarPanel(
        fileInput('fichier1','Choisissez votre fichier excel :',
                  accept = ".xlsx"),
        fluidPage(
      fluidRow(
        column(width = 12,
               numericInput("sheet","Indiquez l'onglet à afficher :",min = 1, value = 1),
               tags$hr(),
               textInput('text',"Indiquez le nom des fichiers :"),
               tags$hr(),
               h4("Pour télécharger les fichiers .csv :"),
               downloadButton("download","Télécharger")
               )
  
      )
    )),
  mainPanel(
    tabsetPanel(
      tabPanel('Importation',
               h4("Fichier de base:"),
               dataTableOutput("contents"))
        )
      )
    )
  )
  </code></pre>
  
  <p>Server :</p>
  
  <pre><code>function(input,output){
  
    #Création data :
    data &lt;- reactive({
      inFile&lt;- input$fichier1
      if (is.null(inFile)){
        return(NULL)
      }else{
        file.rename(inFile$datapath,
                paste(inFile$datapath,".xlsx", sep =""))
        wb = loadWorkbook(paste(inFile$datapath,".xlsx",sep=""))
        lst = readWorksheet(wb,sheet = getSheets(wb))
        list(wb = wb, lst = lst)
      }
    })
  
  
  
    #Sortie de la table :
    output$contents &lt;- renderDataTable({
      data()$wb[input$sheet]
    },options = list(pageLength = 10))
  
  
    #Téléchargement :
    output$download &lt;- downloadHandler(
  
      #for (i in 1:input$sheet){
  
      filename = function(){
        paste(input$text,"_0",3,".csv",sep = "")
      },
      content = function(file){
        write.table(data()$wb[3],file,
                    sep = ';', row.names = F, col.names = T)
      }
  #}
    )
  }
  </code></pre>