Learn R Programming

openxlsx (version 4.2.4)

buildWorkbook: Build Workbook

Description

Build a workbook from a data.frame or named list

Usage

buildWorkbook(x, asTable = FALSE, ...)

Arguments

x

A data.frame or a (named) list of objects that can be handled by writeData or writeDataTable to write to file

asTable

If TRUE will use writeDataTable rather than writeData to write x to the file (default: FALSE)

...

Additional arguments passed to writeData, writeDataTable, setColWidths

Value

A Workbook object

Details

This function can be used as shortcut to create a workbook object from a data.frame or named list. If names are available in the list they will be used as the worksheet names. The parameters in ... are collected and passed to writeData or writeDataTable to initially create the Workbook objects then appropriate parameters are passed to setColWidths.

See Also

write.xlsx

Examples

Run this code
# NOT RUN {
x <- data.frame(a = 1, b = 2)
wb <- buildWorkbook(x)

y <- list(a = x, b = x, c = x)
buildWorkbook(y, asTable = TRUE)
buildWorkbook(y, asTable = TRUE, tableStyle = "TableStyleLight8")

# }

Run the code above in your browser using DataLab