xlsx v0.6.5


Monthly downloads



Read, Write, Format Excel 2007 and Excel 97/2000/XP/2003 Files

Provide R functions to read/write/format Excel 2007 and Excel 97/2000/XP/2003 file formats.


AppVeyor Build Status Travis-CI Build Status CRAN Version

codecov.io 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: 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.


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

Functions in xlsx

Name Description
is.Alignment Create an Alignment object.
is.CellProtection Create a CellProtection object.
Comment Functions to manipulate cell comments.
CellBlock Create and style a block of cells.
CellStyle Functions to manipulate cells.
Cell Functions to manipulate cells.
is.DataFormat Create an DataFormat object.
is.Border Create an Border object.
CellStyle-plus CellStyle construction.
Row Functions to manipulate rows of a worksheet.
Picture Functions to manipulate images in a spreadsheet.
addDataFrame Add a data.frame to a sheet.
Workbook Functions to manipulate Excel 2007 workbooks.
is.Font Create a Font object.
readRows Read a contiguous set of rows into an R matrix
is.Fill Create an Fill object.
NamedRanges Functions to manipulate (contiguous) named ranges.
write.xlsx Write a data.frame to an Excel workbook.
Sheet Functions to manipulate worksheets.
set_java_tmp_dir Set Java Temp Directory
PrintSetup Function to manipulate print setup.
addHyperlink Add a hyperlink to a cell.
xlsx-package Read, write, format Excel 2007 and Excel 97/2000/XP/2003 files
forceFormulaRefresh Force Refresh Pivot Tables and Formulae
read.xlsx Read the contents of a worksheet into an R data.frame.
readColumns Read a contiguous set of columns from sheet into an R data.frame
OtherEffects Functions to do various spreadsheets effects.
POI_constants Constants used in the project.
No Results!

Vignettes of xlsx

No Results!

Last month downloads


Type Package
LazyLoad yes
License GPL-3
URL https://github.com/colearendt/xlsx
BugReports https://github.com/colearendt/xlsx/issues
SystemRequirements java (>= 1.6)
RoxygenNote 7.1.0
VignetteBuilder knitr
NeedsCompilation no
Packaged 2020-11-10 12:06:13 UTC; carendt
Repository CRAN
Date/Publication 2020-11-10 15:00:02 UTC

Include our badge in your README