export_excel: Exports formatted Excel file

View source: R/export_excel.R

export_excelR Documentation

Exports formatted Excel file

Description

Exports Excel sheets with table formatting, headers, auto-column width, etc. Currently does not auto-size columns with dates correctly.

Usage

export_excel(
  df,
  tab_name,
  file_name,
  type = "new",
  col_width = "auto",
  tab_color = NULL,
  table_name = NULL,
  show_tab = TRUE,
  save = TRUE
)

Arguments

df

A data frame, will be exported as an Excel table

tab_name

A string, the name to give to the exported sheet

file_name

A string, the name of the file to be created

type

"new" or "existing", whether to export the sheet as a new stand-alone file (default), or as an addition to an existing file

col_width

optional (defaults to 'auto'), either 'auto' for autosized columns or a vector of numbers which must be equal to the number of columns

tab_color

optional (defaults to none), hex color or color from colors()

table_name

optional (defaults to Table3, Table4, etc.), unique table name in workbook; useful for writing Excel formulas that reference sheets on different tabs

show_tab

optional (defaults to TRUE), whether the sheet exported is shown or hidden

save

optional (defaults to TRUE), whether to save the final Excel workbook; not saving the workbook allows for additional, more complex openxlsx changes,

Value

A new .xlsx file or a new sheet in an existing .xlsx file

Author(s)

Jeremy Pesner, Lillian Nguyen

See Also

export_excel_tabs

Examples

export_excel(iris, "Iris Data","iris.xlsx", "new")

# if using option to resize columns
export_excel(iris, "Iris Data","iris.xlsx", "new", rep(15, 5))


baltimorebudget/bbmR documentation built on Aug. 28, 2023, 6:32 p.m.