Error in export excel with r

this is my code

write.xlsx(as.data.frame(coming_movies), file='test.xlsx', sheetName="Sheet1", col.names=TRUE, row.names=FALSE, append=TRUE)

now my problem is

Error in .jcall(cell, "V", "setCellValue", value) : 
  method setCellValue with signature ([Ljava/lang/String;)V not found
In addition: Warning message:
In if (is.na(value)) { :
  the condition has length > 1 and only the first element will be used

what must i do for this error ??

thank you for anyone who want help me :slight_smile:

Could you please turn this into a self-contained reprex (short for minimal reproducible example)? It will help us help you if we can be sure we're all working with/looking at the same stuff.

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

As @mara said a reprex will make it much easier to solve the problem you have run into. In fact without it it is just about impossible to definitively figure out what is going on with your in your code.

In any case here are some links to people who had a issue that seems to be similar to yours and were able to fix it by changing the class attribute of the data.frame you are working with.

https://github.com/twilbur1997/rexcel/issues/61

https://code.google.com/archive/p/rexcel/issues/55

Also when you get an error message which isn't clear about what the underlying problem is the first thing you should do is a web search for the literal text of at least part of the message. For example searching the web for "Error in .jcall(cell" finds a number of messages similar to the problem your are running into.

2 Likes

What package(s) are you using for going between R and Excel?

library ("xlsx")
library("xlsxjar")

sir, what is reprex and how to used that ??

thank you for help me

okey i learn about reprex and this is my code for export to excel

write.xlsx(as.data.frame(coming_movies), file='test.xlsx', sheetName="Sheet1", col.names=TRUE, row.names=FALSE, append=TRUE)

and

write.xlsx(coming_movies,'D:/coming_soon.xlsx')

Error in .jcall(cell, "V", "setCellValue", value) :
method setCellValue with signature ([Ljava/lang/String;)V not found
In addition: Warning message:
In if (is.na(value)) { :
the condition has length > 1 and only the first element will be used

thank you for anyone wants to help me

It is not really a contribution toward a solution of the error message you have but more like sharing experience.

I find that :package: with JAVA dependency are not easy and I prefer other alternatives without java dependencies if they exists.

hen it comes to deal with Excel, I use this :package:

It relies only on c++ through Rcpp and not an Java.

You could try to write your data.frame in an xlsx file with and maybe you won't have issue anymore.

In your reprex try, you did not provide the coming_movies object. It seems to have some content that you need to deal with before exporting to excel with xlsx :package: . Considering you asked the question and the object name is the same, are you trying to export to excel the result of this question :
https://forum.posit.co/t/how-to-separate-title-from-desc-scraping-data-imdb-coming-soon-movie ?

If this is the case, considering the other post has already a reprex to generate coming_movies

openxlsx::write.xlsx(coming_movies, file = "test.xlsx")

is working for me.

2 Likes

thanks sir, as you see i just want to learn how to use rstudio

@Thenite123 Both times that I've had that error pop up is because I was using 64-bit R/RStudio and my computer had the 32-bit Java installed. You can check which version of R you're using in RStudio by clicking Global Options under Tools. The download from java.com defaults to 32-bit, so you would have to get the 64-bit version from here.

However, I think @cderv's answer should help.