File: excel-sheets.R

package info (click to toggle)
r-cran-readxl 0.1.1-1%2Bdeb9u2
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 1,512 kB
  • sloc: ansic: 4,419; cpp: 2,702; makefile: 1
file content (20 lines) | stat: -rw-r--r-- 616 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#' List all sheets in an excel spreadsheet.
#'
#' @inheritParams read_excel
#' @export
#' @examples
#' excel_sheets(system.file("extdata/datasets.xlsx", package = "readxl"))
#' excel_sheets(system.file("extdata/datasets.xls", package = "readxl"))
#'
#' # To load all sheets in a workbook, use lapply
#' path <- system.file("extdata/datasets.xls", package = "readxl")
#' lapply(excel_sheets(path), read_excel, path = path)
excel_sheets <- function(path) {
  path <- check_file(path)
  ext <- tolower(tools::file_ext(path))

  switch(excel_format(path),
    xls =  xls_sheets(path),
    xlsx = xlsx_sheets(path)
  )
}