RStudio - XLConnect - 加载xlsx工作簿

时间:2016-02-15 11:43:54

标签: rstudio xlsx rjava xlconnect

运行以下代码时:

library(forecast)
Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre7') # for 32-bit 
library(XLConnect)
wb <- loadWorkbook(filename = 'C:/Program Files/R/R-3.2.3/library/XLConnect/demoFiles/mtcars.xlsx')

我收到以下错误:

Error: NoSuchMethodError (Java): org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions;

我与Martin Studer有过接触,问题可能是由多个版本的xmlbeans造成的。

我尝试使用tattletale和jarfish找到这些,但只能找到一个版本xmlbeans-2.6.0.jar。

由于我的java知识不存在,而且我的R知识非常简陋,我需要一些关于如何解决这个问题的具体帮助。

其他感兴趣的事情:

`java -version` --> java version "1.7.0_80"

在R:

中输出sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_3.2.3

cat(getOption("java.stacktrace")):

的输出
java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.setSaveAggressiveNamespaces()Lorg/apache/xmlbeans/XmlOptions;
    at org.apache.poi.POIXMLDocumentPart.<clinit>(POIXMLDocumentPart.java:62)
    at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:86)
    at com.miraisolutions.xlconnect.Workbook.<init>(Workbook.java:92)
    at com.miraisolutions.xlconnect.Workbook.<init>(Workbook.java:99)
    at com.miraisolutions.xlconnect.Workbook.getWorkbook(Workbook.java:1300)
    at com.miraisolutions.xlconnect.Workbook.getWorkbook(Workbook.java:1318)
    at com.miraisolutions.xlconnect.integration.r.RWorkbookWrapper.<init>(RWorkbookWrapper.java:43)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at RJavaTools.newInstance(RJavaTools.java:352)

rJava::.jclassPath():

的输出
 [1] "C:\\Program Files\\R\\R-3.2.3\\library\\rJava\\java"                               
 [2] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnectJars\\java"                       
 [3] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnectJars\\java\\ooxml-schemas-1.1.jar"

 [4] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnectJars\\java\\xmlbeans-2.6.0.jar"   
 [5] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnect\\java"                           
 [6] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnect\\java\\commons-codec-1.9.jar"    
 [7] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnect\\java\\joda-time-2.3.jar"        
 [8] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnect\\java\\poi-3.12-beta1.jar"       
 [9] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnect\\java\\poi-ooxml-3.12-beta1.jar"

[10] "C:\\Program Files\\R\\R-3.2.3\\library\\XLConnect\\java\\XLConnect-0.2-11.jar"  

0 个答案:

没有答案