Learn R Programming

openxlsx2 (version 0.4.1)

wb_load: Load an existing .xlsx file

Description

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

Usage

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

Value

Workbook object.

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.

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.

See Also

wb_remove_worksheet()

Examples

Run this code
## load existing workbook from package folder
wb <- wb_load(file = system.file("extdata", "loadExample.xlsx", package = "openxlsx2"))
wb$get_sheet_names() # list worksheets
wb ## view object
## Add a worksheet
wb$add_worksheet("A new worksheet")

Run the code above in your browser using DataLab