0

I recently installed R 3.2.0 (Windows 64 bit) with packages xlsx, which depends on rJava and xlsxjars. Java 1.8.0_11 64 bit is installed on the machine.

When I try to use the read.xlsx() function, I get the following error about a zipfile:

> library(xlsx)
Loading required package: rJava
Loading required package: xlsxjars
> read.xlsx("cameras.xlsx", sheetIndex=1)

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, : java.util.zip.ZipException: invalid distance too far back

I sure don't know why it would be trying to unzip anything, unless it is one of the jars that comes with the R packages. (The zip files that the R packages came in unzip fine when I do it by hand.) I've re-installed twice to no avail in case of a corruption there.

I feel like there's a config error somewhere, but I'm really stumped. Has anyone else experienced this? Here are the package install messages

> install.packages("xlsx")
Installing package into ‘C:/Users/ggraham412/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
also installing the dependencies ‘rJava’, ‘xlsxjars’

trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/rJava_0.9-6.zip' 
Content type 'application/zip' length 761928 bytes (744 KB)
downloaded 744 KB

trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/xlsxjars_0.6.1.zip'
Content type 'application/zip' length 9485172 bytes (9.0 MB)
downloaded 9.0 MB

trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.2/xlsx_0.5.7.zip'
Content type 'application/zip' length 400857 bytes (391 KB)
downloaded 391 KB

package ‘rJava’ successfully unpacked and MD5 sums checked
package ‘xlsxjars’ successfully unpacked and MD5 sums checked
package ‘xlsx’ successfully unpacked and MD5 sums checked
MichaelChirico
  • 33,841
  • 14
  • 113
  • 198
Greg Graham
  • 473
  • 7
  • 18
  • `xlsx` files are nothing more than zip files really. They have folders and other files inside of them. There are other pacakges out there for reading excel files, you might want to try one of them ([readxl](https://github.com/hadley/readxl) for example which doesn't have a Java dependency) – MrFlick May 06 '15 at 03:12
  • Thanks! My initial search was flawed; since it was my first time using the package (and in the absence of any obvious zip files) I had simply assumed there was a configuration bug. – Greg Graham May 06 '15 at 03:28

1 Answers1

1

Turns out it was the problem described here: R xlsx package error

Didn't know that xlsx file was accessed by zip library in the above process, and indeed I did not download the spreadsheet as binary.

Community
  • 1
  • 1
Greg Graham
  • 473
  • 7
  • 18