write_worksheet: Write Data to an openxlsx Worksheet

View source: R/as_workbook.R

write_worksheetR Documentation

Write Data to an openxlsx Worksheet

Description

This function is similar to openxlsx::writeData() from the package, but rather than just writing data.frames, write_worksheet() supports specialized methods for the various Tatoo_table subclasses.

Usage

write_worksheet(
  x,
  wb,
  sheet,
  append = FALSE,
  start_row = 1L,
  ...,
  named_regions = TRUE,
  named_regions_prefix = NA_character_
)

## S3 method for class 'Tagged_table'
write_worksheet(
  x,
  wb,
  sheet = sanitize_excel_sheet_names(attr(x, "meta")$table_id),
  append = FALSE,
  start_row = 1L,
  ...,
  print_table_id = attr(x, "meta")[[".print_table_id"]],
  named_regions = TRUE,
  named_regions_prefix = NA_character_
)

## S3 method for class 'Composite_table'
write_worksheet(
  x,
  wb,
  sheet,
  append = FALSE,
  start_row = 1L,
  ...,
  named_regions = TRUE,
  named_regions_prefix = NA_character_
)

## S3 method for class 'Mashed_table'
write_worksheet(
  x,
  wb,
  sheet,
  append = FALSE,
  start_row = 1L,
  mash_method = attr(x, "mash_method"),
  id_vars = attr(x, "id_vars"),
  insert_blank_row = attr(x, "insert_blank_row"),
  sep_height = attr(x, "sep_height"),
  ...,
  named_regions = TRUE,
  named_regions_prefix = NA_character_
)

## S3 method for class 'Stacked_table'
write_worksheet(
  x,
  wb,
  sheet,
  append = FALSE,
  start_row = 1L,
  spacing = attr(x, "spacing"),
  ...,
  named_regions = TRUE,
  named_regions_prefix = NA_character_
)

Arguments

x

A Tatoo_table.

wb

An openxlsx Workbook object

sheet

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

append

logical Whether or not to append to an existing worksheet or create a new one

start_row

A scalar integer specifying the starting row to write to.

...

Additional arguments passed on to methods for overriding the styling attributes of the Tatoo_tables you want to export.

named_regions

logical. If TRUE (default) named regions are created in the target excel file to identify different parts of the tables (header, body, column names, etc...). These named regions can, for example, be used for applying formats. Creating named regions can be switched of as this might impact performance of the excel conversion and writing of excel files for workbooks with large numbers of tables.

named_regions_prefix

character scalar. Prefix to write in front of all named regions created by write_worksheet

print_table_id

logical vector. Whether or not table_id should be added to the title of the table. It is recommended to use table_ids only internally (i.e. for walk_regions()).

mash_method

either "row" or "col". Should the tables be mashed together with alternating rows or with alternating columns?

id_vars

If id_vars is specified, the tables will be combined using merge() on the columns specified in id_vars, otherwise the tables will be combined with cbind().

insert_blank_row

Only if mashing rows: logical. Whether to insert blank rows between mash-groups. Warning: this converts all columns to character. Use with care.

sep_height

Only has an effect when exporting to xlsx. if insert_blank_row == TRUE, height of the inserted row, else height of the top row of each mash-group.

spacing

Number of lineskips between the tables when exporting to xlsx

Value

an openxlsx Workbook object

See Also

Other xlsx exporters: as_workbook()


tatoo documentation built on March 31, 2023, 8:16 p.m.