.view <- function(data, withFilter=TRUE, ...) {
# data: a data.frame or a list of data.frames; could be extend to take multiple data.frames.
# withFilter: whether to apply a filter to make sorting and filtering easier
# ...: pass to openxlsx::writeData function
require(openxlsx)
options("openxlsx.dateFormat" = "yyyy-mm-dd")
pars <- match.call()
wb <- createWorkbook()
if (is.data.frame(data)) {
addWorksheet(wb, sheet=as.character(pars$data))
writeData(wb, sheet=as.character(pars$data), data, rowNames = FALSE,
withFilter = withFilter, keepNA=FALSE, ...)
} else if (is.list(data) & length(data) > 1) { # preview the list of data.frame
dfs <- sapply(data, is.data.frame)
addres <- lapply(names(data)[dfs], function(x) {
addWorksheet(wb, sheet=x)
writeData(wb, sheet=x, data[[x]], rowNames = FALSE,
withFilter = withFilter, keepNA=FALSE, ...)
})
}
openXL(wb)
}