R/convertListToExcel.R

Defines functions listToExcel

Documented in listToExcel

#' listToExcel
#' 
#' This simple function exports a list to an excel document. The list elements will be worksheets in Excel
#' @param list_object The list to export
#' @importFrom openxlsx writeData createWorkbook addWorksheet saveWorkbook
#' @export

listToExcel <- function(list_object, fname) {
    w <- createWorkbook()

    invisible({
        lapply(names(list_object), function(n) {
           addWorksheet(w, n)
           writeData(w, n, list_object[[n]],rowNames=TRUE)
        })
    })

    saveWorkbook(w, paste0(fname, ".xlsx"), overwrite = TRUE)
}
hollorol/AgroMo documentation built on July 21, 2023, 8:51 p.m.