wb_workbook: Create a new Workbook object

View source: R/class-workbook-wrappers.R

wb_workbookR Documentation

Create a new Workbook object

Description

This function initializes and returns a wbWorkbook object, which is the core structure for building and modifying openxml files (.xlsx) in openxlsx2.

Usage

wb_workbook(
  creator = NULL,
  title = NULL,
  subject = NULL,
  category = NULL,
  datetime_created = Sys.time(),
  datetime_modified = NULL,
  theme = NULL,
  keywords = NULL,
  comments = NULL,
  manager = NULL,
  company = NULL,
  ...
)

Arguments

creator

Creator of the workbook (your name). Defaults to login username or options("openxlsx2.creator") if set.

title, subject, category, keywords, comments, manager, company

Workbook property, a string.

datetime_created

The time of the workbook is created

datetime_modified

The time of the workbook was last modified

theme

Optional theme identified by string or number. See Details for options.

...

additional arguments

Details

You can define various metadata properties at creation, such as the creator, title, subject, and timestamps. You can also specify a workbook theme.

The returned wb_workbook() object is an R6::R6Class() instance. Once created, the standard workflow is to immediately add a worksheet using wb_add_worksheet(). From there, you can populate the sheet with data (wb_add_data()), or formulas (wb_add_formula()), and apply styling or other elements.

theme can be one of "Atlas", "Badge", "Berlin", "Celestial", "Crop", "Depth", "Droplet", "Facet", "Feathered", "Gallery", "Headlines", "Integral", "Ion", "Ion Boardroom", "LibreOffice", "Madison", "Main Event", "Mesh", "Office 2007 - 2010 Theme", "Office 2013 - 2022 Theme", "Office Theme", "Old Office Theme", "Organic", "Parallax", "Parcel", "Retrospect", "Savon", "Slice", "Vapor Trail", "View", "Wisp", "Wood Type"

Value

A wbWorkbook object

See Also

Other workbook wrappers: base_font-wb, col_widths-wb, creators-wb, grouping-wb, row_heights-wb, wb_add_chartsheet(), wb_add_data(), wb_add_data_table(), wb_add_formula(), wb_add_hyperlink(), wb_add_pivot_table(), wb_add_slicer(), wb_add_worksheet(), wb_base_colors, wb_clone_worksheet(), wb_copy_cells(), wb_freeze_pane(), wb_merge_cells(), wb_save(), wb_set_last_modified_by()

Examples

## Create a new workbook
wb <- wb_workbook()

## Set Workbook properties
wb <- wb_workbook(
  creator  = "Me",
  title    = "Expense Report",
  subject  = "Expense Report - 2022 Q1",
  category = "sales"
)

## Cloning a workbook
wb1 <- wb_workbook()
wb2 <- wb1$clone(deep = TRUE)

openxlsx2 documentation built on Jan. 16, 2026, 5:06 p.m.