Skip to contents

This function wraps `openxlsx::addWorksheet` and adds data to the newly created sheet. If the sheet already exists, it issues a warning and clears the existing content.

Usage

xlsxAddSheet(wb, sheetName, dt)

Arguments

wb

A workbook object created by `openxlsx::loadWorkbook()`.

sheetName

A character string specifying the name of the sheet to add.

dt

A `data.table` containing the data to be written to the new sheet.

Value

An invisible NULL value. The function performs an action (adding a sheet)

See also

Other function to read from and write to xlsx: setHeadersToLowerCase(), splitInputs(), xlsxAddDataUsingTemplate(), xlsxCloneAndSet(), xlsxReadData(), xlsxWriteData()

Examples

if (FALSE) { # \dontrun{
library(openxlsx)
wb <- loadWorkbook("example.xlsx")
data <- data.table(Name = c("Alice", "Bob"), Age = c(30, 25))
xlsxAddSheet(wb, "NewSheet", data)
} # }