is.excel.file: is the file a Microsoft Excel XLS or XLSX file?

Description Usage Arguments Value Author(s) See Also Examples

View source: R/is.excel.file.R

Description

Rather than just checking the file extension, this function checks whether the contents of the file are a Microsoft Excel file, using the GNU file program, thus this will not work on Windows. file works by checking the file signature to see what file type it is. Note that XLS files can have different file signatures depending where they are saved from/created.

Usage

1
2
3
4
5

Arguments

path

a character vector: the path(s) to file(s) which must exist

Value

A logical vector of length(path), where the values are TRUE if the path is an XLS, XLSX, or both, FALSE otherwise, for is.xls.file, is.xlsx.file, or is.excel.file, respectively.

Author(s)

Mark Cowley, 2012-02-01

See Also

is.xls.file is.xlsx.file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# df <- data.frame(A=1:10, B=letters[1:10], C=LETTERS[1:10], D=TRUE, E=FALSE)
require(datasets)
write.table(iris, "tmp.tsv", quote=FALSE, sep="\t")
write.csv(iris, "tmp.csv")
require(dataframes2xls)
write.xls(iris, "tmp.xls")
require(xlsx)
write.xlsx(iris, "tmp.xlsx")

is.excel.file("./tmp.xls")
is.excel.file("./tmp.xlsx")
is.excel.file("./tmp.tsv")
is.excel.file("./tmp.csv")
is.excel.file(c("./tmp.xls", "./tmp.xlsx", "./tmp.tsv", "./tmp.csv"))

## End(Not run)

drmjc/excelIO documentation built on Aug. 3, 2019, 5:16 p.m.