Cell {xlsx} | R Documentation |
Functions to manipulate cells.
createCell(row, colIndex=1:5) getCells(row, simplify=TRUE) setCellValue(cell, value, richTextString=FALSE) getCellValue(cell, keepFormulas=FALSE)
row |
a list of row objects. See Row . |
colIndex |
a numeric vector specifying the index of columns to create. |
simplify |
a logical value. If TRUE , the result will be
unlisted. |
value |
an R variable of length one. |
richTextString |
a logical value indicating if the value should be inserted into the Excel cell as rich text. |
keepFormulas |
a logical value. If TRUE the formulas will
be returned as characters instead of being explicitly evaluated. |
cell |
an object of type Cell . |
setCellValue
writes the content of an R variable into the cell.
Date
and POSIXct
objects are passed in as numerical
values. To format them as dates in Excel see CellStyle
.
This function is not vectorized.
createCell
creates a matrix of lists, each element of the list
being a java object reference to an object of type Cell representing
an empty cell. The dimnames of this matrix are taken from the names
of the rows and the colIndex
variable.
getCells
returns a list of java object references for all the
cells in the row.
getCellValue
returns the value in the cell as an R object.
Type conversions are done behind the scene. This function is not
vectorized.
Adrian Dragulescu
To format cells, see CellStyle
.
file <- system.file("tests", "test_import.xlsx", package = "xlsx") wb <- loadWorkbook(file) sheets <- getSheets(wb) sheet <- sheets[[2]] # get second sheet rows <- getRows(sheet) # get all the rows cells <- getCells(rows) # returns all non empty cells values <- lapply(cells, getCellValue) # extract the values