The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

AppVeyor Build Status Travis-CI Build Status CRAN Version

codecov.io CRAN Activity CRAN History

xlsx

An R package to read, write, format Excel 2007 and Excel 97/2000/XP/2003 files

The package provides R functions to read, write, and format Excel files. It depends on Java, but this makes it available on most operating systems.

Install

Stable version from CRAN

install.packages('xlsx')

Or development version from GitHub

devtools::install_github('colearendt/xlsx')

Common Problems

This package depends on Java and the rJava package to make the connection between R and Java seamless. In order to use the xlsx package, you will need to:

More detail can be found in the rJava docs.

Quick start

To read the first sheet from spreadsheet into a data.frame

read.xlsx2('file.xlsx', 1)

To write a data.frame to a spreadsheet

write.xlsx2(iris, file='iris.xlsx')

The package has many functions that make it easy to style and formalize output into Excel, as well.

wb <- createWorkbook()
s <- createSheet(wb,'test')

cs <- CellStyle(wb) + 
  Font(wb,heightInPoints = 16, isBold = TRUE) +
  Alignment(horizontal='ALIGN_CENTER')
  

r <- createRow(s,1)
cell <- createCell(r,1:ncol(iris))

setCellValue(cell[[1]],'Title for Iris')
for (i in cell) {
  setCellStyle(i,cs)
}

addMergedRegion(s, 1,1, 1,ncol(iris))

addDataFrame(iris, s, row.names=FALSE, startRow=3)

saveWorkbook(wb,'iris_pretty.xlsx')

Issues/Mailing list

To report a bug, use the Issues page at: https://github.com/colearendt/xlsx/issues

If you are wrestling with the Java dependency, there are some very good alternatives that do not require Java. Your choice will vary depending on what you are trying to accomplish.

Acknowledgements

The package is made possible thanks to the excellent work on Apache POI.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.