Download Excel by using R Shiny
<p>I want to build a web app that can download excel files. BUT I have a problem when I use the web app: After I click the "Download" button, it shows that the file name is in quotes like the picture I uploaded, and I can't find anything in my documents after I click the "Save" button, whether I delete the quotes or not.</p>

<p><a href="https://i.stack.imgur.com/dR7Fl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dR7Fl.png" alt="enter image description here"></a></p>

<p>Does anyone have a good suggestion to solve this problem? 
Thank you for your help.</p>

<pre><code>library(shiny)
library(shinydashboard)
library(XLConnect)

ui &lt;- dashboardPage(
  dashboardHeader(title = "excel download"),
  dashboardSidebar(downloadLink("downloadData", "Download")),
  dashboardBody(),
  skin = "purple"
)

server &lt;- function(input, output) {
  data1 &lt;- mtcars
  output$downloadData &lt;- downloadHandler(
    filename = function(){"mtcars.xlsx"},
    content = function(file) {
      fname &lt;- paste(file,"xlsx",sep=".")
      wb &lt;- loadWorkbook(fname,create = TRUE)
      createSheet(wb,"cars")
      writeWorksheet(wb,data = data1,sheet = "cars")
      saveWorkbook(wb)
      file.rename(fname,file)
    },
    contentType="application/xlsx" 
  )
}

shinyApp(ui = ui, server = server)
</code></pre>