Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package "xlsx" unusable after having used package "xlconnect" #95

Closed
TillF opened this issue May 16, 2018 · 1 comment
Closed

package "xlsx" unusable after having used package "xlconnect" #95

TillF opened this issue May 16, 2018 · 1 comment

Comments

@TillF
Copy link

TillF commented May 16, 2018

Because of complementary functionality I want to use "xlsx" after package "xlconnect".
However, the code snippet, which works when issued alone, fails when executed after having used "xlconnect" in the same session.

#A: usage of XLConnect ####
library(XLConnect)
wb <- XLConnect::loadWorkbook(file = paste0(tempfile(),".xlsx"), create = TRUE)  #create an empty xlsx 
# unload package and its dependencies
try(detach("package:XLConnect", unload=TRUE, force = TRUE), silent = TRUE)
try(detach("package:XLConnectJars", unload=TRUE, force = TRUE), silent = TRUE)
try(detach("package:rJava", unload=TRUE, force = TRUE), silent = TRUE)


#B: usage of xlsx ####
library(xlsx)
wb <- createWorkbook()
cs <- CellStyle(wb) +        #create a cell style
  Font(wb, heightInPoints=20) + 
  Fill(backgroundColor="lavender")
-> error

Error message:

Error in .jcall(cellStyle, "V", "setFillPattern", .jshort(CS[fill$pattern])) : method setFillPattern with signature (S)V not found

There is a complementary error when using the packages in the reverse order (miraisolutions/xlconnect#79).

Is there a workaround for this except restarting R?

sessionInfo()
R version 3.5.0 (2018-04-23)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
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] compiler_3.5.0 rJava_0.9-9

@colearendt
Copy link
Owner

As the related issue suggests, this is not something that is supported. Both packages are trying to use the same underlying Java library and therefore have some conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants