49
read.xlsx
33
Examples
wb <- createWorkbook()
addWorksheet(wb, "S1")
addWorksheet(wb, "S2")
writeDataTable(wb, 1, x = iris[1:30,])
writeDataTable(wb, 2, x = iris[1:30,], xy = c("C", 5))
## landscape page scaled to 50%
pageSetup(wb, sheet = 1, orientation = "landscape", scale = 50)
## portrait page scales to 300% with 0.5in left and right margins
pageSetup(wb, sheet = 2, orientation = "portrait", scale = 300, left= 0.5, right = 0.5)
saveWorkbook(wb, "pageSetupExample.xlsx", overwrite = TRUE)
read.xlsx
Read data from an Excel file or Workbook object into a data.frame
Description
Read data from an Excel file or Workbook object into a data.frame
Usage
read.xlsx(xlsxFile, sheet = 1, startRow = 1, colNames = TRUE,
rowNames = FALSE, detectDates = FALSE, skipEmptyRows = TRUE,
rows = NULL, cols = NULL, check.names = FALSE, namedRegion = NULL)
Arguments
xlsxFile
An xlsx file or Workbook object
sheet
The name or index of the sheet to read data from.
startRow
first row to begin looking for data. Empty rows at the top of a file are always
skipped,regardless of the value ofstartRow.
colNames
If TRUE, the first row ofdata will be used as column names.
rowNames
If TRUE, first column ofdata will be used as row names.
detectDates
If TRUE, attempt to recognise dates and perform conversion.
skipEmptyRows If TRUE, empty rows are skipped else empty rows after the first row containing
data will return a row of NAs.
rows
Anumeric vector specifying which rows in the Excel file to read. If NULL, all
rows are read.
cols
Anumeric vector specifying which columns in the Excel file to read. If NULL,
all columns are read.
check.names
logical. If TRUE then the names of the variables in the data frame are checked
to ensure that they are syntactically valid variable names
namedRegion
Anamedregionin theWorkbook. IfnotNULL startRow,rows and cols paramters
are ignored.