write.xlsx: Write to Microsoft Excel XLSX file

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/write.xlsx.R

Description

Write a matrix or data.frame to a genuine Microsoft Excel XLSX file. The first row is bold, italics, dashed underline. Columns are centred.

Usage

1
2
write.xlsx(x, xlsx, verbose = FALSE, row.names = FALSE, col.names = TRUE,
  ...)

Arguments

x

either a data.frame, or a list of data.frames. if a list of data.frames, then each data.frame will become a worksheet in the resulting workbook.

xlsx

the xlsx file to be created.

verbose

logical: print messages?

row.names

DIFFERENT TO write.table. Can be either TRUE, FALSE, NULL, NA, or a character(1). if TRUE then row.names will be written out, with a blank column header, if FALSE, then no row names will be written out, if NULL or NA, then rownames will be written out with no column name (just like write.table(row.names=TRUE) would do) if row.names is a character vector of length 1, then write the row.names out, and use use the supplied word as the column name for the rownames else error

col.names

logical: If TRUE then write out the column names.

...

additional arguments passed to write.delim

Details

Uses a perl module called Excel::Writer::XLSX, by John McNamara, a perl program called tab2xlsx, based on a program of the same name also by JM. This R code borrows the structure from gdata's excellent read.xls function.

Value

none. writes an excel 'xlsx' file.

Note

Installation It's not that widely tested, but this package does include the necessary perl libraries to write XLSX files. If you're struggling though, install the 'Excel::Writer::XLSX' Perl module via CPAN or similar. For OSX users, this involves:
sudo perl -e shell -MCPAN
install Excel::Writer::XLSX

Author(s)

Mark Cowley, 2009-01-20. Updated 2016-04-14 to write XLSX files.

See Also

write.xls write.table read.delim read.xls

Examples

1
2
3
4
f <- tempfile(fileext=".xlsx")
write.xlsx(iris, f)
x <- list(A=iris[1:5, ], B=iris)
write.xlsx(x, f)

drmjc/excelIO documentation built on Aug. 3, 2019, 5:16 p.m.