wb_load returns a workbook object conserving styles and formatting of the original .xlsx file.

wb_load(file, xlsxFile = NULL, sheet, data_only = FALSE, calc_chain = FALSE)

## Arguments

file

A path to an existing .xlsx or .xlsm file

xlsxFile

alias for file

sheet

optional sheet parameter. if this is applied, only the selected sheet will be loaded.

data_only

mode to import if only a data frame should be returned. This strips the wbWorkbook to a bare minimum.

calc_chain

optionally you can keep the calculation chain intact. This is used by spreadsheet software to identify the order in which formulas are evaluated. Removing the calculation chain is considered harmless. The calc chain will be created upon the next time the worksheet is loaded in spreadsheet software. Keeping it, might only speed loading time in said software.

Workbook object.

## Details

A warning is displayed if an xml namespace for main is found in the xlsx file. Certain xlsx files created by third-party applications contain a namespace (usually x). This namespace is not required for the file to work in spreadsheet software and is not expected by openxlsx2. Therefore it is removed when the file is loaded into a workbook. Removal is generally expected to be safe, but the feature is still experimental.

wb_remove_worksheet()
## load existing workbook from package folder
wb$get_sheet_names() # list worksheets #> IrisSample testing mtcars mtCars Pivot #> "IrisSample" "testing" "mtcars" "mtCars Pivot" wb ## view object #> A Workbook object. #> #> Worksheets: #> Sheets: IrisSample testing mtcars mtCars Pivot #> Write order: 1, 2, 3, 4 ## Add a worksheet wb$add_worksheet("A new worksheet")