Learn R Programming

openxlsx2 (version 0.8)

wbWorkbook: R6 class for a Workbook

Description

A workbook

Arguments

Public fields

sheet_names

sheet_names

calcChain

calcChain

charts

charts

is_chartsheet

is_chartsheet

customXml

customXml

connections

connections

ctrlProps

ctrlProps

Content_Types

Content_Types

app

app

core

core

custom

custom

drawings

drawings

drawings_rels

drawings_rels

embeddings

embeddings

externalLinks

externalLinks

externalLinksRels

externalLinksRels

headFoot

headFoot

media

media

metadata

metadata

persons

persons

pivotTables

pivotTables

pivotTables.xml.rels

pivotTables.xml.rels

pivotDefinitions

pivotDefinitions

pivotRecords

pivotRecords

pivotDefinitionsRels

pivotDefinitionsRels

queryTables

queryTables

slicers

slicers

slicerCaches

slicerCaches

sharedStrings

sharedStrings

styles_mgr

styles_mgr

tables

tables

tables.xml.rels

tables.xml.rels

theme

theme

vbaProject

vbaProject

vml

vml

vml_rels

vml_rels

comments

comments

threadComments

threadComments

workbook

workbook

workbook.xml.rels

workbook.xml.rels

worksheets

worksheets

worksheets_rels

worksheets_rels

sheetOrder

The sheet order. Controls ordering for worksheets and worksheet names.

path

path

creator

A character vector of creators

title

title

subject

subject

category

category

datetimeCreated

The datetime (as POSIXt) the workbook is created. Defaults to the current Sys.time() when the workbook object is created, not when the Excel files are saved.

Methods

Public methods


Method new()

Creates a new wbWorkbook object

Usage

wbWorkbook$new(
  creator = NULL,
  title = NULL,
  subject = NULL,
  category = NULL,
  datetime_created = Sys.time(),
  theme = NULL,
  ...
)

Arguments

creator

character vector of creators. Duplicated are ignored.

title

title

subject

subject

category

category

datetime_created

The datetime (as POSIXt) the workbook is created. Defaults to the current Sys.time() when the workbook object is created, not when the Excel files are saved.

theme

Optional theme identified by string or number

...

additional arguments

Returns

a wbWorkbook object


Method append()

Append a field. This method is intended for internal use

Usage

wbWorkbook$append(field, value)

Arguments

field

A valid field name

value

A value for the field


Method append_sheets()

Append to self$workbook$sheets This method is intended for internal use

Usage

wbWorkbook$append_sheets(value)

Arguments

value

A value for self$workbook$sheets


Method validate_sheet()

validate sheet

Usage

wbWorkbook$validate_sheet(sheet)

Arguments

sheet

A character sheet name or integer location

Returns

The integer position of the sheet


Method add_chartsheet()

Add a chart sheet to the workbook

Usage

wbWorkbook$add_chartsheet(
  sheet = next_sheet(),
  tab_color = NULL,
  zoom = 100,
  visible = c("true", "false", "hidden", "visible", "veryhidden"),
  ...
)

Arguments

sheet

sheet

tab_color

tab_color

zoom

zoom

visible

visible

...

...

Returns

The wbWorkbook object, invisibly


Method add_worksheet()

Add worksheet to the wbWorkbook object

Usage

wbWorkbook$add_worksheet(
  sheet = next_sheet(),
  grid_lines = TRUE,
  row_col_headers = TRUE,
  tab_color = NULL,
  zoom = 100,
  header = NULL,
  footer = NULL,
  odd_header = header,
  odd_footer = footer,
  even_header = header,
  even_footer = footer,
  first_header = header,
  first_footer = footer,
  visible = c("true", "false", "hidden", "visible", "veryhidden"),
  has_drawing = FALSE,
  paper_size = getOption("openxlsx2.paperSize", default = 9),
  orientation = getOption("openxlsx2.orientation", default = "portrait"),
  hdpi = getOption("openxlsx2.hdpi", default = getOption("openxlsx2.dpi", default = 300)),
  vdpi = getOption("openxlsx2.vdpi", default = getOption("openxlsx2.dpi", default = 300)),
  ...
)

Arguments

sheet

sheet

grid_lines

gridLines

row_col_headers

rowColHeaders

tab_color

tabColor

zoom

zoom

header

header

footer

footer

odd_header

oddHeader

odd_footer

oddFooter

even_header

evenHeader

even_footer

evenFooter

first_header

firstHeader

first_footer

firstFooter

visible

visible

has_drawing

hasDrawing

paper_size

paperSize

orientation

orientation

hdpi

hdpi

vdpi

vdpi

...

...

Returns

The wbWorkbook object, invisibly


Method clone_worksheet()

Clone a workbooksheet

Usage

wbWorkbook$clone_worksheet(old = current_sheet(), new = next_sheet())

Arguments

old

name of worksheet to clone

new

name of new worksheet to add


Method add_data()

add data

Usage

wbWorkbook$add_data(
  sheet = current_sheet(),
  x,
  dims = wb_dims(start_row, start_col),
  start_col = 1,
  start_row = 1,
  array = FALSE,
  col_names = TRUE,
  row_names = FALSE,
  with_filter = FALSE,
  name = NULL,
  sep = ", ",
  apply_cell_style = TRUE,
  remove_cell_style = FALSE,
  na.strings = na_strings(),
  inline_strings = TRUE,
  ...
)

Arguments

sheet

sheet

x

x

dims

dims

start_col

startCol

start_row

startRow

array

array

col_names

colNames

row_names

rowNames

with_filter

withFilter

name

name

sep

sep

apply_cell_style

applyCellStyle

remove_cell_style

if writing into existing cells, should the cell style be removed?

na.strings

Value used for replacing NA values from x. Default na_strings() uses the special #N/A value within the workbook.

inline_strings

write characters as inline strings

...

additional arguments

return

The wbWorkbook object


Method add_data_table()

add a data table

Usage

wbWorkbook$add_data_table(
  sheet = current_sheet(),
  x,
  dims = wb_dims(start_row, start_col),
  start_col = 1,
  start_row = 1,
  col_names = TRUE,
  row_names = FALSE,
  table_style = "TableStyleLight9",
  table_name = NULL,
  with_filter = TRUE,
  sep = ", ",
  first_column = FALSE,
  last_column = FALSE,
  banded_rows = TRUE,
  banded_cols = FALSE,
  apply_cell_style = TRUE,
  remove_cell_style = FALSE,
  na.strings = na_strings(),
  inline_strings = TRUE,
  ...
)

Arguments

sheet

sheet

x

x

dims

dims

start_col

startCol

start_row

startRow

col_names

colNames

row_names

rowNames

table_style

tableStyle

table_name

tableName

with_filter

withFilter

sep

sep

first_column

firstColumn

last_column

lastColumn

banded_rows

bandedRows

banded_cols

bandedCols

apply_cell_style

applyCellStyle

remove_cell_style

if writing into existing cells, should the cell style be removed?

na.strings

Value used for replacing NA values from x. Default na_strings() uses the special #N/A value within the workbook.

inline_strings

write characters as inline strings

...

additional arguments

Returns

The wbWorkbook object


Method add_pivot_table()

add pivot table

Usage

wbWorkbook$add_pivot_table(
  x,
  sheet = next_sheet(),
  dims = "A3",
  filter,
  rows,
  cols,
  data,
  fun,
  params
)

Arguments

x

a wb_data object

sheet

a worksheet

dims

the worksheet cell where the pivot table is placed

filter

a character object with names used to filter

rows

a character object with names used as rows

cols

a character object with names used as cols

data

a character object with names used as data

fun

a character object of functions to be used with the data

params

a list of parameters to modify pivot table creation

Details

fun can be either of AVERAGE, COUNT, COUNTA, MAX, MIN, PRODUCT, STDEV, STDEVP, SUM, VAR, VARP

Returns

The wbWorkbook object


Method add_formula()

add formula

Usage

wbWorkbook$add_formula(
  sheet = current_sheet(),
  x,
  dims = wb_dims(start_row, start_col),
  start_col = 1,
  start_row = 1,
  array = FALSE,
  cm = FALSE,
  apply_cell_style = TRUE,
  remove_cell_style = FALSE,
  ...
)

Arguments

sheet

sheet

x

x

dims

dims

start_col

startCol

start_row

startRow

array

array

cm

cm

apply_cell_style

applyCellStyle

remove_cell_style

if writing into existing cells, should the cell style be removed?

...

additional arguments

Returns

The wbWorkbook object


Method add_style()

add style

Usage

wbWorkbook$add_style(style = NULL, style_name = NULL)

Arguments

style

style

style_name

style_name

Returns

The wbWorkbook object


Method to_df()

to_df

Usage

wbWorkbook$to_df(
  sheet,
  start_row = 1,
  start_col = NULL,
  row_names = FALSE,
  col_names = TRUE,
  skip_empty_rows = FALSE,
  skip_empty_cols = FALSE,
  skip_hidden_rows = FALSE,
  skip_hidden_cols = FALSE,
  rows = NULL,
  cols = NULL,
  detect_dates = TRUE,
  na.strings = "#N/A",
  na.numbers = NA,
  fill_merged_cells = FALSE,
  dims,
  show_formula = FALSE,
  convert = TRUE,
  types,
  named_region,
  keep_attributes = FALSE,
  ...
)

Arguments

sheet

Either sheet name or index. When missing the first sheet in the workbook is selected.

start_row

first row to begin looking for data.

start_col

first column to begin looking for data.

row_names

If TRUE, the first col of data will be used as row names.

col_names

If TRUE, the first row of data will be used as column names.

skip_empty_rows

If TRUE, empty rows are skipped.

skip_empty_cols

If TRUE, empty columns are skipped.

skip_hidden_rows

If TRUE, hidden rows are skipped.

skip_hidden_cols

If TRUE, hidden columns are skipped.

rows

A numeric vector specifying which rows in the Excel file to read. If NULL, all rows are read.

cols

A numeric vector specifying which columns in the Excel file to read. If NULL, all columns are read.

detect_dates

If TRUE, attempt to recognize dates and perform conversion.

na.strings

A character vector of strings which are to be interpreted as NA. Blank cells will be returned as NA.

na.numbers

A numeric vector of digits which are to be interpreted as NA. Blank cells will be returned as NA.

fill_merged_cells

If TRUE, the value in a merged cell is given to all cells within the merge.

dims

Character string of type "A1:B2" as optional dimensions to be imported.

show_formula

If TRUE, the underlying Excel formulas are shown.

convert

If TRUE, a conversion to dates and numerics is attempted.

types

A named numeric indicating, the type of the data. 0: character, 1: numeric, 2: date, 3: posixt, 4:logical. Names must match the returned data

named_region

Character string with a named_region (defined name or table). If no sheet is selected, the first appearance will be selected.

keep_attributes

If TRUE additional attributes are returned. (These are used internally to define a cell type.)

...

additional arguments

Returns

a data frame


Method load()

load workbook

Usage

wbWorkbook$load(file, sheet, data_only = FALSE, calc_chain = FALSE, ...)

Arguments

file

file

sheet

sheet

data_only

data_only

calc_chain

calc_chain

...

additional arguments

Returns

The wbWorkbook object invisibly


Method save()

Save the workbook

Usage

wbWorkbook$save(file = self$path, overwrite = TRUE, path = NULL)

Arguments

file

The path to save the workbook to

overwrite

If FALSE, will not overwrite when path exists

path

Deprecated argument previously used for file. Please use file in new code.

Returns

The wbWorkbook object invisibly


Method open()

open wbWorkbook in Excel.

Usage

wbWorkbook$open(interactive = NA)

Arguments

interactive

If FALSE will throw a warning and not open the path. This can be manually set to TRUE, otherwise when NA (default) uses the value returned from base::interactive()

Details

minor helper wrapping xl_open which does the entire same thing

Returns

The wbWorkbook, invisibly


Method buildTable()

Build table

Usage

wbWorkbook$buildTable(
  sheet = current_sheet(),
  colNames,
  ref,
  showColNames,
  tableStyle,
  tableName,
  withFilter,
  totalsRowCount = 0,
  showFirstColumn = 0,
  showLastColumn = 0,
  showRowStripes = 1,
  showColumnStripes = 0
)

Arguments

sheet

sheet

colNames

colNames

ref

ref

showColNames

showColNames

tableStyle

tableStyle

tableName

tableName

withFilter

withFilter

totalsRowCount

totalsRowCount

showFirstColumn

showFirstColumn

showLastColumn

showLastColumn

showRowStripes

showRowStripes

showColumnStripes

showColumnStripes

Returns

The wbWorksheet object, invisibly


Method update_table()

update a data_table

Usage

wbWorkbook$update_table(sheet = current_sheet(), dims = "A1", tabname)

Arguments

sheet

a worksheet

dims

cell used as start

tabname

a tablename

Returns

The wbWorksheet object, invisibly


Method copy_cells()

copy cells around in a workbook

Usage

wbWorkbook$copy_cells(
  sheet = current_sheet(),
  dims = "A1",
  data,
  as_value = FALSE,
  as_ref = FALSE,
  transpose = FALSE
)

Arguments

sheet

a worksheet

dims

cell used as start

data

a wb_data object

as_value

should a copy of the value be written

as_ref

should references to the cell be written

transpose

should the data be written transposed

Returns

The wbWorksheet object, invisibly


Method get_base_font()

Get the base font

Usage

wbWorkbook$get_base_font()

Returns

A list of of the font


Method set_base_font()

Get the base font

Usage

wbWorkbook$set_base_font(
  font_size = 11,
  font_color = wb_color(theme = "1"),
  font_name = "Calibri",
  ...
)

Arguments

font_size

fontSize

font_color

font_color

font_name

font_name

...

...

Returns

The wbWorkbook object


Method set_bookview()

Set the book views

Usage

wbWorkbook$set_bookview(
  active_tab = NULL,
  auto_filter_date_grouping = NULL,
  first_sheet = NULL,
  minimized = NULL,
  show_horizontal_scroll = NULL,
  show_sheet_tabs = NULL,
  show_vertical_scroll = NULL,
  tab_ratio = NULL,
  visibility = NULL,
  window_height = NULL,
  window_width = NULL,
  x_window = NULL,
  y_window = NULL,
  ...
)

Arguments

active_tab

activeTab

auto_filter_date_grouping

autoFilterDateGrouping

first_sheet

firstSheet

minimized

minimized

show_horizontal_scroll

showHorizontalScroll

show_sheet_tabs

showSheetTabs

show_vertical_scroll

showVerticalScroll

tab_ratio

tabRatio

visibility

visibility

window_height

windowHeight

window_width

windowWidth

x_window

xWindow

y_window

yWindow

...

additional arguments

Returns

The wbWorkbook object


Method get_sheet_names()

Get sheet names

Usage

wbWorkbook$get_sheet_names()

Returns

A named character vector of sheet names in their order. The names represent the original value of the worksheet prior to any character substitutions.


Method set_sheet_names()

Sets a sheet name

Usage

wbWorkbook$set_sheet_names(old = NULL, new)

Arguments

old

Old sheet name

new

New sheet name

Returns

The wbWorkbook object, invisibly


Method set_row_heights()

Sets a row height for a sheet

Usage

wbWorkbook$set_row_heights(
  sheet = current_sheet(),
  rows,
  heights = NULL,
  hidden = FALSE
)

Arguments

sheet

sheet

rows

rows

heights

heights

hidden

hidden

Returns

The wbWorkbook object, invisibly


Method remove_row_heights()

Sets a row height for a sheet

Usage

wbWorkbook$remove_row_heights(sheet = current_sheet(), rows)

Arguments

sheet

sheet

rows

rows

Returns

The wbWorkbook object, invisibly description creates column object for worksheet


Method createCols()

Usage

wbWorkbook$createCols(sheet = current_sheet(), n, beg, end)

Arguments

sheet

sheet

n

n

beg

beg

end

end


Method group_cols()

Group cols

Usage

wbWorkbook$group_cols(
  sheet = current_sheet(),
  cols,
  collapsed = FALSE,
  levels = NULL
)

Arguments

sheet

sheet

cols

cols

collapsed

collapsed

levels

levels

Returns

The wbWorkbook object, invisibly


Method ungroup_cols()

ungroup cols

Usage

wbWorkbook$ungroup_cols(sheet = current_sheet(), cols)

Arguments

sheet

sheet

cols

= cols

Returns

The wbWorkbook object


Method remove_col_widths()

Remove row heights from a worksheet

Usage

wbWorkbook$remove_col_widths(sheet = current_sheet(), cols)

Arguments

sheet

A name or index of a worksheet

cols

Indices of columns to remove custom width (if any) from.

Returns

The wbWorkbook object, invisibly


Method set_col_widths()

Group cols

Usage

wbWorkbook$set_col_widths(
  sheet = current_sheet(),
  cols,
  widths = 8.43,
  hidden = FALSE
)

Arguments

sheet

sheet

cols

cols

widths

Width of columns

hidden

A logical vector to determine which cols are hidden; values are repeated across length of cols

Returns

The wbWorkbook object, invisibly


Method group_rows()

Group rows

Usage

wbWorkbook$group_rows(
  sheet = current_sheet(),
  rows,
  collapsed = FALSE,
  levels = NULL
)

Arguments

sheet

sheet

rows

rows

collapsed

collapsed

levels

levels

Returns

The wbWorkbook object, invisibly


Method ungroup_rows()

ungroup rows

Usage

wbWorkbook$ungroup_rows(sheet = current_sheet(), rows)

Arguments

sheet

sheet

rows

rows

Returns

The wbWorkbook object


Method remove_worksheet()

Remove a worksheet

Usage

wbWorkbook$remove_worksheet(sheet = current_sheet())

Arguments

sheet

The worksheet to delete

Returns

The wbWorkbook object, invisibly


Method add_data_validation()

Adds data validation

Usage

wbWorkbook$add_data_validation(
  sheet = current_sheet(),
  dims = "A1",
  type,
  operator,
  value,
  allow_blank = TRUE,
  show_input_msg = TRUE,
  show_error_msg = TRUE,
  error_style = NULL,
  error_title = NULL,
  error = NULL,
  prompt_title = NULL,
  prompt = NULL,
  ...
)

Arguments

sheet

sheet

dims

cell dimension

type

type

operator

operator

value

value

allow_blank

allowBlank

show_input_msg

showInputMsg

show_error_msg

showErrorMsg

error_style

The icon shown and the options how to deal with such inputs. Default "stop" (cancel), else "information" (prompt popup) or "warning" (prompt accept or change input)

error_title

The error title

error

The error text

prompt_title

The prompt title

prompt

The prompt text

...

additional arguments

Returns

The wbWorkbook object


Method merge_cells()

Set cell merging for a sheet

Usage

wbWorkbook$merge_cells(sheet = current_sheet(), dims = NULL, ...)

Arguments

sheet

sheet

dims

worksheet cells

...

additional arguments

Returns

The wbWorkbook object, invisibly


Method unmerge_cells()

Removes cell merging for a sheet

Usage

wbWorkbook$unmerge_cells(sheet = current_sheet(), dims = NULL, ...)

Arguments

sheet

sheet

dims

worksheet cells

...

additional arguments

Returns

The wbWorkbook object, invisibly


Method freeze_pane()

Set freeze panes for a sheet

Usage

wbWorkbook$freeze_pane(
  sheet = current_sheet(),
  first_active_row = NULL,
  first_active_col = NULL,
  first_row = FALSE,
  first_col = FALSE,
  ...
)

Arguments

sheet

sheet

first_active_row

first_active_row

first_active_col

first_active_col

first_row

first_row

first_col

first_col

...

additional arguments

Returns

The wbWorkbook object, invisibly


Method add_comment()

Add comment

Usage

wbWorkbook$add_comment(sheet = current_sheet(), dims = "A1", comment, ...)

Arguments

sheet

sheet

dims

row and column as spreadsheet dimension, e.g. "A1"

comment

a comment to apply to the worksheet

...

additional arguments

Returns

The wbWorkbook object


Method remove_comment()

Remove comment

Usage

wbWorkbook$remove_comment(sheet = current_sheet(), dims = "A1", ...)

Arguments

sheet

sheet

dims

row and column as spreadsheet dimension, e.g. "A1"

...

additional arguments

Returns

The wbWorkbook object


Method add_thread()

add threaded comment to worksheet

Usage

wbWorkbook$add_thread(
  sheet = current_sheet(),
  dims = "A1",
  comment = NULL,
  person_id,
  reply = FALSE,
  resolve = FALSE
)

Arguments

sheet

a worksheet

dims

a cell

comment

the comment to add

person_id

the person Id this should be added for

reply

logical if the comment is a reply

resolve

logical if the comment should be marked as resolved


Method add_conditional_formatting()

Add conditional formatting

Usage

wbWorkbook$add_conditional_formatting(
  sheet = current_sheet(),
  dims = NULL,
  rule = NULL,
  style = NULL,
  type = c("expression", "colorScale", "dataBar", "iconSet", "duplicatedValues",
    "uniqueValues", "containsErrors", "notContainsErrors", "containsBlanks",
    "notContainsBlanks", "containsText", "notContainsText", "beginsWith", "endsWith",
    "between", "topN", "bottomN"),
  params = list(showValue = TRUE, gradient = TRUE, border = TRUE, percent = FALSE, rank =
    5L),
  ...
)

Arguments

sheet

sheet

dims

dims

rule

rule

style

style

type

type

params

Additional parameters

...

additional arguments

Returns

The wbWorkbook object


Method add_image()

Insert an image into a sheet

Usage

wbWorkbook$add_image(
  sheet = current_sheet(),
  dims = "A1",
  file,
  width = 6,
  height = 3,
  row_offset = 0,
  col_offset = 0,
  units = "in",
  dpi = 300,
  ...
)

Arguments

sheet

sheet

dims

dims

file

file

width

width

height

height

row_offset, col_offset

offsets

units

units

dpi

dpi

...

additional arguments

Returns

The wbWorkbook object, invisibly


Method add_plot()

Add plot. A wrapper for add_image()

Usage

wbWorkbook$add_plot(
  sheet = current_sheet(),
  dims = "A1",
  width = 6,
  height = 4,
  row_offset = 0,
  col_offset = 0,
  file_type = "png",
  units = "in",
  dpi = 300,
  ...
)

Arguments

sheet

sheet

dims

dims

width

width

height

height

row_offset, col_offset

offsets

file_type

fileType

units

units

dpi

dpi

...

additional arguments

Returns

The wbWorkbook object


Method add_drawing()

Add xml drawing

Usage

wbWorkbook$add_drawing(
  sheet = current_sheet(),
  dims = "A1",
  xml,
  col_offset = 0,
  row_offset = 0,
  ...
)

Arguments

sheet

sheet

dims

dims

xml

xml

col_offset, row_offset

offsets for column and row

...

additional arguments

Returns

The wbWorkbook object


Method add_chart_xml()

Add xml drawing

Add xml chart

Usage

wbWorkbook$add_chart_xml(
  sheet = current_sheet(),
  dims = NULL,
  xml,
  col_offset = 0,
  row_offset = 0,
  ...
)

Arguments

sheet

sheet

dims

dims

xml

xml

col_offset, row_offset

positioning parameters

...

additional arguments

Returns

The wbWorkbook object


Method add_mschart()

Add mschart chart to the workbook

Usage

wbWorkbook$add_mschart(
  sheet = current_sheet(),
  dims = NULL,
  graph,
  col_offset = 0,
  row_offset = 0,
  ...
)

Arguments

sheet

the sheet on which the graph will appear

dims

the dimensions where the sheet will appear

graph

mschart graph

col_offset, row_offset

offsets for column and row

...

additional arguments

Returns

The wbWorkbook object


Method add_form_control()

add form control to workbook

Usage

wbWorkbook$add_form_control(
  sheet = current_sheet(),
  dims = "A1",
  type = NULL,
  text = NULL,
  link = NULL,
  range = NULL,
  checked = FALSE
)

Arguments

sheet

sheet

dims

dims

type

type

text

text

link

link

range

range

checked

checked

Returns

The wbWorkbook object, invisibly


Method print()

Prints the wbWorkbook object

Usage

wbWorkbook$print()

Returns

The wbWorkbook object, invisibly; called for its side-effects


Method protect()

Protect a workbook

Usage

wbWorkbook$protect(
  protect = TRUE,
  password = NULL,
  lock_structure = FALSE,
  lock_windows = FALSE,
  type = 1,
  file_sharing = FALSE,
  username = unname(Sys.info()["user"]),
  read_only_recommended = FALSE,
  ...
)

Arguments

protect

protect

password

password

lock_structure

lock_structure

lock_windows

lock_windows

type

type

file_sharing

file_sharing

username

username

read_only_recommended

read_only_recommended

...

additional arguments

Returns

The wbWorkbook object, invisibly


Method protect_worksheet()

protect worksheet

Usage

wbWorkbook$protect_worksheet(
  sheet = current_sheet(),
  protect = TRUE,
  password = NULL,
  properties = NULL
)

Arguments

sheet

sheet

protect

protect

password

password

properties

A character vector of properties to lock. Can be one or more of the following: "selectLockedCells", "selectUnlockedCells", "formatCells", "formatColumns", "formatRows", "insertColumns", "insertRows", "insertHyperlinks", "deleteColumns", "deleteRows", "sort", "autoFilter", "pivotTables", "objects", "scenarios"

Returns

The wbWorkbook object


Method set_creators()

Set creator(s)

Usage

wbWorkbook$set_creators(creators)

Arguments

creators

A character vector of creators to set. Duplicates are ignored.


Method add_creators()

Add creator(s)

Usage

wbWorkbook$add_creators(creators)

Arguments

creators

A character vector of creators to add. Duplicates are ignored.


Method remove_creators()

Remove creator(s)

Usage

wbWorkbook$remove_creators(creators)

Arguments

<

See Also

create_border

Examples

Run this code

## ------------------------------------------------
## Method `wbWorkbook$add_border`
## ------------------------------------------------


wb <- wb_workbook()
wb$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_border(1, dims = "A1:K1",
 left_border = NULL, right_border = NULL,
 top_border = NULL, bottom_border = "double")
wb$add_border(1, dims = "A5",
 left_border = "dotted", right_border = "dotted",
 top_border = "hair", bottom_border = "thick")
wb$add_border(1, dims = "C2:C5")
wb$add_border(1, dims = "G2:H3")
wb$add_border(1, dims = "G12:H13",
 left_color = wb_color(hex = "FF9400D3"), right_color = wb_color(hex = "FF4B0082"),
 top_color = wb_color(hex = "FF0000FF"), bottom_color = wb_color(hex = "FF00FF00"))
wb$add_border(1, dims = "A20:C23")
wb$add_border(1, dims = "B12:D14",
 left_color = wb_color(hex = "FFFFFF00"), right_color = wb_color(hex = "FFFF7F00"),
 bottom_color = wb_color(hex = "FFFF0000"))
wb$add_border(1, dims = "D28:E28")
# if (interactive()) wb$open()

wb <- wb_workbook()
wb$add_worksheet("S1")$add_data("S1", mtcars)
wb$add_border(1, dims = "A2:K33", inner_vgrid = "thin", inner_vcolor = c(rgb="FF808080"))

## ------------------------------------------------
## Method `wbWorkbook$add_fill`
## ------------------------------------------------

 # example from the gradient fill manual page
 gradient_fill <- "
   
   
  "

## ------------------------------------------------
## Method `wbWorkbook$add_font`
## ------------------------------------------------

 wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
 wb$add_font("S1", "A1:K1", name = "Arial", color = wb_color(theme = "4"))

## ------------------------------------------------
## Method `wbWorkbook$add_numfmt`
## ------------------------------------------------

 wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
 wb$add_numfmt("S1", "A1:A33", numfmt = 1)

## ------------------------------------------------
## Method `wbWorkbook$add_cell_style`
## ------------------------------------------------

 wb <- wb_workbook()$add_worksheet("S1")$add_data("S1", mtcars)
 wb$add_cell_style("S1", "A1:K1",
                   textRotation = "45",
                   horizontal = "center",
                   vertical = "center",
                   wrapText = "1")

Run the code above in your browser using DataLab