Skip to content
An R package to interact with Excel files using the Apache POI java library
R Java
Branch: develop
Clone or download
Latest commit d570b7f Dec 10, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
R fix compare version Dec 9, 2018
inst fix line endings Sep 4, 2018
java make CRAN bot happy Jun 11, 2018
man fix typo Oct 10, 2018
other fix line endings Sep 4, 2018
resources fix line endings Sep 4, 2018
tests add a few expected failures Dec 10, 2018
.Rbuildignore Add appveyor and travis badges Sep 29, 2018
.gitattributes add gitattributes file Sep 4, 2018
.gitignore update gitignore Sep 4, 2018
.travis.yml add ci config Sep 4, 2018
DESCRIPTION bump version Sep 29, 2018
NAMESPACE fix line endings Sep 4, 2018
NEWS add bullet for news Sep 29, 2018 Update Sep 29, 2018
appveyor.yml allow failures for devel release Sep 27, 2018

AppVeyor Build Status Travis-CI Build Status CRAN Version CRAN Activity CRAN History


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.


Stable version from CRAN


Or development version from GitHub


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:

  • Ensure you have a jdk (Java Development Kit, version >= 1.5) installed for your Operating System. More information can be found on Oracle's website

  • Ensure that the system environment variable JAVA_HOME is configured appropriately and points to your jdk of choice. Typically, this will be included in your PATH environment variable as well. Options and system environmental variables that are available from R can be seen with Sys.getenv()

  • Particularly on UNIX systems, if you continue experiencing issues, you may need to reconfigure R's support for Java on your system. From a terminal, use the command R CMD javareconf. You may need to run this as root or prepended with sudo to ensure it has appropriate permission.

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) +

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

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

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

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


Issues/Mailing list

To report a bug, use the Issues page at:

Questions should be asked on the dedicated mailing list


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

You can’t perform that action at this time.