The result consists of a list of lists, if as.data.frame
is set to FALSE
.
Be then prepared to encounter NULL
values. Those will prevent from easily being able to coerce
the square data structure to a data.frame.The following code will replace the NULL
values by NA
and coerce the data to a data.frame.
# get the range D1:J69 from an excel file
xlrng <- XLGetRange(file="myfile.xlsx", sheet="Tabelle1",
range="D1:J69", as.data.frame=FALSE)
# replace NULL values by NA
xlrng[unlist(lapply(xlrng, is.null))] <- NA
# coerce the square data structure to a data.frame
d.lka <- data.frame(lapply(data.frame(xlrng), unlist))
This of course can be avoided by setting as.data.frame
= TRUE
.
The function will return dates as integer values, because XL stores them as integers.
An Excel date can be converted with the (unusual) origin of
as.Date(myDate, origin="1899-12-30")
. See also XLDateToPOSIXct
, which does the job.