xlsx_write.xlsx: Write a data.frame to an Excel workbook

View source: R/xlsx.R

xlsx_write.xlsxR Documentation

Write a data.frame to an Excel workbook

Description

Write a data.frame to an Excel workbook

Usage

xlsx_write.xlsx(
  x,
  file,
  sheetName = "Sheet1",
  col.names = TRUE,
  row.names = FALSE,
  append = FALSE,
  showNA = FALSE,
  forceAppend = FALSE
)

Arguments

x

a data.frame to write to the workbook.

file

the path to the output file.

sheetName

a character string with the sheet name.

col.names

a logical value indicating if the column names of x are to be written along with x to the file.

row.names

a logical value indicating whether the row names of x are to be written along with x to the file.

append

a logical value indicating if x should be appended to an existing file. If TRUE the file is read from disk.

showNA

a logical value. If set to FALSE, NA values will be left as empty cells.

forceAppend

overwrite the sheet if it exists

Note

This is a forked version of xlsx::write.xlsx() that avoids the error issued by attempting to write an empty data frame. If the data frame has zero rows, xlsx:::.write_block() is skipped and the file is saved with just the column names. The fork also includes a new argument forceAppend which allows to overwrite the sheet if it already exists.

References

Handling empty data frame with write.xlsx # nolint


the-mad-statter/washu documentation built on May 5, 2024, 10:26 a.m.