excel_format {readxl}R Documentation

Determine file format

Description

Determine if files are xls or xlsx (or from the xlsx family).

excel_format(guess = TRUE) is used by read_excel() to determine format. It draws on logic from two lower level functions:

File extensions associated with xlsx vs. xls:

File signatures (in hexadecimal) for xlsx vs xls:

Usage

excel_format(path, guess = TRUE)

format_from_ext(path)

format_from_signature(path)

Arguments

path

Path to the xls/xlsx file.

guess

Logical. If the file extension is absent or not recognized, this controls whether we attempt to guess format based on the file signature or "magic number".

Value

Character vector with values "xlsx", "xls", or NA.

Examples

files <- c(
  "a.xlsx",
  "b.xls",
  "c.png",
  file.path(R.home("doc"), "html", "logo.jpg"),
  readxl_example("clippy.xlsx"),
  readxl_example("deaths.xls")
)
excel_format(files)

[Package readxl version 1.4.3 Index]