Error loading xlsx package

余生颓废 提交于 2019-12-22 10:23:43

问题


yesterday we migrated to windows 7 in our firm and also updated the java packages and also R (to 2.14).

Then I tried to load the xlsx package, because I rely heavly on it but i get the following error:

Error : .onAttach in attachNamespace()
Error: .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")

I tried the following, but it did not work:

Sys.setenv(PATH=paste(Sys.getenv("PATH"),"C:\\Program Files (x86)\\Java\\jre6\\bin\\client",collapse=';')) 
options(java.parameters = "-Xmx1000m")

Since I never work with java i have no clue what I can do. Can you help me?

Thank you!

sessionInfo() R version 2.14.1 (2011-12-22) Platform: i386-pc-mingw32/i386 (32-bit)

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

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

other attached packages: [1] xlsxjars_0.4.0 rJava_0.9-3

loaded via a namespace (and not attached): [1] tools_2.14.1 xlsx_0.4.2


The interesting thing is, that the package XLConnect loads without problems.EDIT: Ok, it loads without problems but loading a workbook does not work:

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

So maybe it is really no Java problem. But I don't want to re-write all my code to XLConnect!

Nobody any ideas what I could try?


回答1:


I encountered exactly the same error and found a work-around. If you specify a library location on the network to install the package into, the error occurs.

## Example where error occurs: 
install.packages('xlsx', lib='\\network\R\library')
library('xlsx', lib='\\network\R\library'))

However, if you change the default location for package installation within R, then you should be able to call the package library without the error. That is, simply typing install.packages('xlsx'), and having the package install automatically to its default location, allowed the package to work properly.



来源:https://stackoverflow.com/questions/10697744/error-loading-xlsx-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!