Learn R Programming

openxlsx2 (version 0.3.1)

wb_add_formula: Add a character vector as an Excel Formula

Description

Add a character vector containing Excel formula to a worksheet.

Usage

wb_add_formula(
  wb,
  sheet = current_sheet(),
  x,
  startCol = 1,
  startRow = 1,
  dims = rowcol_to_dims(startRow, startCol),
  array = FALSE,
  xy = NULL,
  applyCellStyle = TRUE,
  removeCellStyle = FALSE
)

Arguments

wb

A Workbook object containing a worksheet.

sheet

The worksheet to write to. Can be the worksheet index or name.

x

A character vector.

startCol

A vector specifying the starting column to write to.

startRow

A vector specifying the starting row to write to.

dims

Spreadsheet dimensions that will determine startCol and startRow: "A1", "A1:B2", "A:B"

array

A bool if the function written is of type array

xy

An alternative to specifying startCol and startRow individually. A vector of the form c(startCol, startRow).

applyCellStyle

Should we write cell styles to the workbook

removeCellStyle

keep the cell style?

Details

Currently only the English version of functions are supported. Please don't use the local translation. The examples below show a small list of possible formulas:

  • SUM(B2:B4)

  • AVERAGE(B2:B4)

  • MIN(B2:B4)

  • MAX(B2:B4)

  • ...

See Also

Other workbook wrappers: wb_add_data_table(), wb_add_data(), wb_add_worksheet(), wb_clone_worksheet(), wb_creators, wb_freeze_pane(), wb_get_base_font(), wb_save(), wb_set_col_widths(), wb_set_last_modified_by(), wb_set_row_heights(), wb_workbook(), workbook_grouping, ws_cell_merge