Read data from an Excel file or Workbook object into a data.frame
read_xlsx(
xlsxFile,
sheet,
startRow = 1,
startCol = NULL,
rowNames = FALSE,
colNames = TRUE,
skipEmptyRows = FALSE,
skipEmptyCols = FALSE,
rows = NULL,
cols = NULL,
detectDates = TRUE,
namedRegion,
na.strings = "#N/A",
na.numbers = NA,
check.names = FALSE,
sep.names = ".",
fillMergedCells = FALSE,
...
)
data.frame
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.
first column to begin looking for data.
If TRUE
, first column of data will be used as row names.
If TRUE
, the first row of data will be used as column names.
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.
If TRUE
, attempt to recognize dates and perform conversion.
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.
A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA.
logical. If TRUE then the names of the variables in the data frame are checked to ensure that they are syntactically valid variable names
(unimplemented) One character which substitutes blanks in column names. By default, "."
If TRUE, the value in a merged cell is given to all cells within the merge.
additional arguments passed to wb_to_df()
Formulae written using write_formula to a Workbook object will not get picked up by read_xlsx(). This is because only the formula is written and left to be evaluated when the file is opened in Excel. Opening, saving and closing the file with Excel will resolve this.
wb_get_named_regions()
wb_to_df()
xlsxFile <- system.file("extdata", "openxlsx2_example.xlsx", package = "openxlsx2")
read_xlsx(xlsxFile = xlsxFile)
Run the code above in your browser using DataLab