I have an excel file with different sheets, and I want to read it in the server side, while in the ui side the user uploads the file.
Since I have a large code I can't paste it here that's why I will use a little example:
library(shiny)
library(readxl)
shinyApp(
ui = fluidPage(
fileInput("file","Upload the file")
),
server = function(input, output) {
sheets <- readxl::excel_sheets(input$file$datapath)
x <- lapply(sheets, function(X) readxl::read_excel(input$file$datapath, sheet = X))
names(x) <- sheets
}
)
But unfortunately I get an error, the function can't find the file given a datapath. But what is interesting is when I use the fread()
function it recognizes the file in input$file$datapath
but it can't read .xlsx files.
I have already tried the solutions in this question but it didn't work, somehow the paste paste()
function returns 0.xlsx and my file is like fileName.xlsx, any solution would be very helpful.