各位好,写了一段代码,用来下载excel文件,可是每次点开生成的文件都带有双引号,比如“cars.xlsx”,把双引号去掉后,再在保存地方查找,却什么都没有下载下来。
有谁了解是什么情况吗?
library(shiny)
library(shinydashboard)
library(XLConnect)
# Define UI for application that draws a histogram
ui <- dashboardPage(
dashboardHeader(title = "excel download"),
dashboardSidebar(downloadLink("downloadData", "Download")),
dashboardBody(),
skin = "purple"
)
# Define server logic required to draw a histogram
server <- function(input, output) {
data1 <- mtcars
output$downloadData <- downloadHandler(
filename = function(){"mtcars.xlsx"},
content = function(file) {
fname <- paste(file,"xlsx",sep=".")
wb <- loadWorkbook(fname,create = TRUE)
createSheet(wb,"cars")
writeWorksheet(wb,data = data1,sheet = "cars")
saveWorkbook(wb)
file.rename(fname,file)
},
contentType="application/xlsx"
)
}
# Run the application
shinyApp(ui = ui, server = server)
有谁了解是什么情况吗?
library(shiny)
library(shinydashboard)
library(XLConnect)
# Define UI for application that draws a histogram
ui <- dashboardPage(
dashboardHeader(title = "excel download"),
dashboardSidebar(downloadLink("downloadData", "Download")),
dashboardBody(),
skin = "purple"
)
# Define server logic required to draw a histogram
server <- function(input, output) {
data1 <- mtcars
output$downloadData <- downloadHandler(
filename = function(){"mtcars.xlsx"},
content = function(file) {
fname <- paste(file,"xlsx",sep=".")
wb <- loadWorkbook(fname,create = TRUE)
createSheet(wb,"cars")
writeWorksheet(wb,data = data1,sheet = "cars")
saveWorkbook(wb)
file.rename(fname,file)
},
contentType="application/xlsx"
)
}
# Run the application
shinyApp(ui = ui, server = server)