I want an api which can upload a xlsx file,which select by the user.The api should take any xlsx file as a input.
1 Answer
#* @post /upload_excel
#* @param f:file
#* @param sheet:str
#* @param range:str
function(f, sheet, range) {
tmp <- tempfile("plumb", fileext = paste0("_", basename(names(f))))
on.exit(unlink(tmp))
writeBin(f[[1]], tmp)
t <- readxl::read_excel(tmp, sheet, range)
nrow(t)
}
-
1
-
-
From github.com/rstudio/plumber/issues/681#issuecomment-700318254. you can use
readxl::read_xlsx
instead. See the doc for more information. Nov 3, 2020 at 18:57