I am trying to insert an R dataframe
from Rstudio to an already existing Excel sheet without overwriting the entire file. I already tried this solution, but the instruction loadWorkbook
gives me this error:
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException
With this traceback:
6.
stop(structure(list(message = "org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException", call = .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, .jcast(if (inherits(o, "jobjRef") || inherits(o, "jarrayRef")) o else cl, "java/lang/Object"), .jnew("java/lang/String", ...
5.
.jcheck(silent = FALSE)
4.
.jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, .jcast(if (inherits(o, "jobjRef") || inherits(o, "jarrayRef")) o else cl, "java/lang/Object"), .jnew("java/lang/String", method), j_p, j_pc, use.true.class = TRUE, evalString = simplify, ...
3.
.jrcall(x, name, ...)
2.
wbFactory$create(inputStream)
1.
loadWorkbook("Recon Metro Fuels JR B VN Ene 2019 V2.xlsx")
I am using the libraries:
pdftools
, for extracting text from a PDF.openxlsx
&xlsx
, for Excel manipulation.dplyr
, for the%>%
operator.
For more information about the Excel, Size: 29MB
, is in .xlsx file format.
Here is the code on how i'm doing it:
#load exel file
old_data<- readWorkbook("Recon Metro Fuels JR B VN Ene 2019 V2.xlsx", sheet = "Raw BAC VN CON FIREFOX");
#Combines the Excel sheet with the new updated sheet
new_data<-bind_rows(old_data, pdf_refined);
wb<- loadWorkbook("Recon Metro Fuels JR B VN Ene 2019 V2.xlsx")
What causes this error? Are there other ways to do it?