title: Putting images into xlsx docs through Shiny on shiny-server
body: <p>I believe I'm running into permission issues between a working shiny app running though RStudio on my laptop and shiny-server on ubuntu. </p>
  
  <p>This sample app for instance will write an image in an xlsx doc and let you download the xlsx.  It will work in rstudio running shiny locally but not through shiny-server.  I'm guessing that there is a way to write the png in a secure way temporarily and call it back for writing to the xlsx that is kosher with shiny-server. </p>
  
  <p><strong>server.R</strong></p>
  
  <pre><code>library(shiny);library(openxlsx);library(ggplot2)
  
  shinyServer(function(input, output) {
  
    output$downloadReport &lt;- downloadHandler(
      filename = "test.xlsx",
      content = function(file){
        wb &lt;- createWorkbook(paste0(Sys.time(), ".xlsx"))
        my_plot &lt;- ggplot(mtcars) + geom_line(aes(x = cyl, y = gear))
        worksheet_name &lt;- "ggplot"
  
        addWorksheet(wb, worksheet_name)
        png("plot.png", width=1024, height=768, units="px", res=144)
        print(my_plot)
        dev.off()  
        insertImage(wb, worksheet_name, "plot.png", width=11.18, height=7.82, units="in")
  
        saveWorkbook(wb, file, overwrite = TRUE)
      })
  })
  </code></pre>
  
  <p><strong>ui.R</strong></p>
  
  <pre><code>library(shiny)
  
  shinyUI(fluidPage(
    sidebarLayout(
      sidebarPanel(
        helpText(),
        downloadButton('downloadReport')),
      mainPanel()
    ))
  )
  </code></pre>