Reading Excel: evaluation error with zip file '..file.xlsx' cannot be opened

拥有回忆 提交于 2019-12-01 15:03:00

The error message is readxl's funny way of saying "file not found". That exact line of code gives me the exact same error, and the file doesn't even exist for me.

Note: I'm on version 1.0.0 of readxl

I had this error, but for me, it was just that I had the sheet open in Excel while trying to read it into R. I guess the package wrongly perceives it as a zip file when it's trying to read it while Excel has partial ownership of it (and this blocks the read).

You can specify a path to a file, only if it is nested on the working directory. For example: If your working directory is MyWD and there is a folder in it, named MyData and another folder within MyData named MyNestedData, and finally myExcelFile.xlsx

read_excel("MyData/MyNestedData/myExcelFile.xlsx",sheet = "Sheet2") #will work
read_excel("MyWD/MyData/MyNestedData/myExcelFile.xlsx",sheet = "Sheet2") #will not work

If your excel worksheet is password protected, read_excel won't be able to access it and will give you this error. If it needs protection, I would suggest p/w protecting the folder it's in, and then unprotecting the worksheet.

This can happen if you forget to do the following before you use the read_excel function

setwd("C:\\map\\map_in_map\\map_in_map_in_map_where_the_file_is")

You may try to specify the full path instead of ./path/to/file

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