Export Rstudio data to EXCEL


Hi all,

I have created a new dataset in Rstudio, and I would like to export it into an Excel file. I saw that I could use the xlsx package, but then errors come up:
'Error: package 'rJava' could not be loaded'.

I have read that I should install a new java program on my computer, which I did (64 bits). However, this also does not seem to work.

Does anybody know how to help me with this? Is there another package?

How to export R results to Excel

I've found the openxlsx package to be easier to use than the xlsx package. It also doesn't have a java dependency. The main command for directly writing a data frame to an Excel file is write.xlsx. You can also create worksheets, do lots of fancy formatting and write multiple tables to a worksheet (see the vignettes here for some examples), but start with write.xlsx for basic creation of Excel files.


Hi Joels, thanks for your help.
After I installed the openxlsx package, I wrote:
write.xlsx(daily, "daily.xlsx")
The name of my data is called 'daily'.

However, I got an error message:
Zipping up workbook failed. Please make sure Rtools is installed or a zip application is available to R. Try installr::install.rtools() on Windows.

I have now installed rtools from the internet, but I still get the same error message.


try restarting RStudio/R, if you have not already. iir the installer makes path changes which don't show up until a restart.


You can also try the rather new package writexl. The writexl package is also free from the java dependency.



write_xlsx(x = daily, path = "daily.xlsx", col_names = TRUE)


Regarding your java installation. Make sure that it isn't the 32-bit R version you use if you have installed 64-bit java. It's a while ago I've had any issues, but I vaguely remember I had some problems because of this.


Thank you all so much!!! I got the problem fixed now thanks to you guys!


I'd like to add a strong endorsement for writexl. If it does what you need, it's great to design away the external dependencies the other packages require.