Learn R Programming

openxlsx2 (version 0.3.1)

write_data2: dummy function to write data

Description

dummy function to write data

Usage

write_data2(
  wb,
  sheet,
  data,
  name = NULL,
  colNames = TRUE,
  rowNames = FALSE,
  startRow = 1,
  startCol = 1,
  applyCellStyle = TRUE,
  removeCellStyle = FALSE,
  na.strings,
  data_table = FALSE
)

Arguments

wb

workbook

sheet

sheet

data

data to export

name

If not NULL, a named region is defined.

colNames

include colnames?

rowNames

include rownames?

startRow

row to place it

startCol

col to place it

applyCellStyle

apply styles when writing on the sheet

removeCellStyle

keep the cell style?

na.strings

optional na.strings argument. if missing #N/A is used. If NULL no cell value is written, if character or numeric this is written (even if NA is part of numeric data)

data_table

logical. if TRUE and rowNames = TRUE, do not write the cell containing "_rowNames_"

Details

The string "_openxlsx_NA" is reserved for openxlsx2. If the data frame contains this string, the output will be broken.

Examples

Run this code
# create a workbook and add some sheets
wb <- wb_workbook()

wb$add_worksheet("sheet1")
write_data2(wb, "sheet1", mtcars, colNames = TRUE, rowNames = TRUE)

wb$add_worksheet("sheet2")
write_data2(wb, "sheet2", cars, colNames = FALSE)

wb$add_worksheet("sheet3")
write_data2(wb, "sheet3", letters)

wb$add_worksheet("sheet4")
write_data2(wb, "sheet4", as.data.frame(Titanic), startRow = 2, startCol = 2)

Run the code above in your browser using DataLab