academic.user
academic.user

Reputation: 679

write.xlsx error in Error in .jnew and j.check in R

I was trying to write a dataframe with 523370 rows and 3 columns using write.xlsx

write.xlsx(x = dataframe, file = "dataframe.xlsx",
+ sheetName = "dataframe1", row.names = FALSE)

but I get this error :

    Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") : 
  Java Exception <no description because toString() failed>.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")<S4 object of class "jobjRef">

and I check these question :

But that changed the error changed to:

Error in .jcheck(silent = FALSE) :Java Exception <no description because toString() failed>.jcall(row[[ir]], "Lorg/apache/poi/ss/usermodel/Cell;", "createCell", as.integer(colIndex[ic] - 1))<S4 object of class "jobjRef">

Upvotes: 11

Views: 27792

Answers (6)

Shashank raizada
Shashank raizada

Reputation: 21

Use this line :

openxlsx::write.xlsx(x = dataframe, file = "dataframe.xlsx")

It worked for me ...

Upvotes: 2

Scipione Sarlo
Scipione Sarlo

Reputation: 1498

Try to use write.xlsx from openxlsx package that does not use java.

openxlsx::write.xlsx(x = dataframe, file = "dataframe.xlsx")

Upvotes: 15

nthobservation
nthobservation

Reputation: 119

I had a similar problem and used write.csv() instead and then saved the csv file as .xlsx from excel. That did the trick.

Upvotes: -3

xpan
xpan

Reputation: 31

I get the same error when I use the relative path. You can try to use the absolute paths.

  • R version 3.4.4 (2018-03-15)
  • Platform: x86_64-pc-linux-gnu (64-bit)
  • Running under: Ubuntu 16.04.4 LTS

Upvotes: 0

Tom&#225;s Barcellos
Tom&#225;s Barcellos

Reputation: 824

I had the same problem and restarting R did the trick.

If you're using RStudio the keystroke shortcut for restarting R is Ctrl + Shift + F10 (PC) or Command + Shift + F10 (Mac).

Upvotes: 18

Jeremy Demlow
Jeremy Demlow

Reputation: 1

You can always use read.csv() and then just save it and a xlsx file if the problem continues.

Upvotes: -4

Related Questions