Learn R Programming

xlsx (version 0.1.1)

write.xlsx: Write a data.frame to an Excel 2007 workbook.

Description

Write a data.frame to an Excel 2007 workbook.

Usage

write.xlsx(x, file, sheetName="Sheet 1", formatTemplate=NULL,
  col.names=TRUE, row.names=TRUE)

Arguments

x
a data.frame to write to the workbook.
file
the absolute path to the file which the data are to be read from.
sheetName
a character string with the sheet name.
formatTemplate
Not implemented now. A way for specifying the formatting of the table.
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.

Details

This function provides a high level API for writing a data.frame to an Excel 2007 worksheet. It calls several low level functions in the process. Its goal is to provide the conveniency of write.csv by borrowing from its signature.

Internally, there is a double loop in Rover all the elements of the data.frame so performance for very large data.frame may be an issue. Please report if you experience slow performance. Dates and POSIXct classes are formatted separately after the insertion. This also adds to processing time.

See Also

read.xlsx for reading xlsx documents. See also saveWorkbook for reading a workbook into R for further processing and saveWorkbook for saving a workbook to file.

Examples

Run this code
file <- paste(tempdir(), "/usarrests.xlsx", sep="")
res <- write.xlsx(USArrests, file)

Run the code above in your browser using DataLab