Read data from an Excel file or Workbook object into a data.frame
readWorkbook(
xlsxFile,
sheet = 1,
startRow = 1,
colNames = TRUE,
rowNames = FALSE,
detectDates = FALSE,
skipEmptyRows = TRUE,
skipEmptyCols = TRUE,
rows = NULL,
cols = NULL,
check.names = FALSE,
sep.names = ".",
namedRegion = NULL,
na.strings = "NA",
fillMergedCells = FALSE
)
An xlsx file, Workbook object or URL to xlsx file.
The name or index of the sheet to read data from.
first row to begin looking for data. Empty rows at the top of a file are always skipped, regardless of the value of startRow.
If TRUE
, the first row of data will be used as column names.
If TRUE
, first column of data will be used as row names.
If TRUE
, attempt to recognise dates and perform conversion.
If TRUE
, empty rows are skipped else empty rows after the first row containing data
will return a row of NAs.
If TRUE
, empty columns are skipped.
A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.
A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.
logical. If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names
One character which substitutes blanks in column names. By default, "."
A named region in the Workbook. If not NULL startRow, rows and cols parameters are ignored.
A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.
If TRUE, the value in a merged cell is given to all cells within the merge.
data.frame
Creates a data.frame of all data in worksheet.
xlsxFile <- system.file("extdata", "readTest.xlsx", package = "openxlsx")
df1 <- readWorkbook(xlsxFile = xlsxFile, sheet = 1)
xlsxFile <- system.file("extdata", "readTest.xlsx", package = "openxlsx")
df1 <- readWorkbook(xlsxFile = xlsxFile, sheet = 1, rows = c(1, 3, 5), cols = 1:3)