Java R xlsx 包错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28325744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
R xlsx package error
提问by user3758532
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.util.zip.ZipException: invalid code -- missing end-of-block
Does anyone have this error when you try to use
当您尝试使用时,是否有人遇到此错误
dat <- read.xlsx("data.xlsx", sheetIndex=1, colIndex=colIndex, rowIndex=rowIndex)?
回答by Richard Border
The version of java you have installed is likely incompatible with the xslx package. Try replacing your default java with the 64 bit version: https://www.java.com/en/download/faq/java_win64bit.xml.
您安装的 java 版本可能与 xslx 包不兼容。尝试用 64 位版本替换默认的 java:https: //www.java.com/en/download/faq/java_win64bit.xml。
回答by Deep-B
I had this problem with a file downloaded from the internet using R command line, for an online course. Found that apparently the download mode needs to be set properly as write-binary (wb) since xlsx is basically a binary file (zip). Who knew?
对于使用 R 命令行从 Internet 下载的在线课程,我遇到了这个问题。发现显然下载模式需要正确设置为写入二进制(wb),因为 xlsx 基本上是一个二进制文件(zip)。谁知道?
If that's what you did too, re-download the file with the mode set properly; like:
如果您也是这样做的,请使用正确设置的模式重新下载文件;喜欢:
download.file(fileUrl, destfile='./data/sample.xlsx', mode='wb')