0

I tried installing java and using the XLConnect package mmethods (both of them) but I get an error that looks like this:

Error: IOException (Java): Your InputStream was neither an OLE2 stream, nor an OOXML stream

I am definitely not trying to load an empty file, and I definitely do have access to/permission to read from the file location. What might I be doing wrong?

I tried installing java and using the XLConnect package mmethods (both of them) but I get an error that looks like this:

Error: IOException (Java): Your InputStream was neither an OLE2 stream, nor an OOXML stream

I am definitely not trying to load an empty file, and I definitely do have access to/permission to read from the file location. What might I be doing wrong?

I've investigated these related questions without success.

Importing Excel files into R, xlsx or xls

R read_excel: libxls error: Unable to parse file

  • Depending on what `.xls` version was used, it might actually be a `.xml`. See: https://github.com/tidyverse/readxl/issues/635#issuecomment-734504530 – Justin Singh-M. Jan 29 '21 at 16:26
  • I just checked it out, based on what I read, I'm not sure of a good diagnostic i.e. how can I tell if it's an XML or not? – Jairaj Ranchod Jan 29 '21 at 16:43
  • You can try renaming the extension of the file and opening it that way, or use the `xml2` package to open it in R and see if that works (`xml2::read_xml()`). If that doesn't work, can you open the `.xls` and save it again as a `.xlsx`? – Justin Singh-M. Jan 29 '21 at 17:28
  • This is actually for a folder of slx files so I'm hoping to find a function I can use with sapply() to do it automatically. I tried read_xml() and got an error. I actually just found a VBA script to auto-convert my files to csv so that will work in the interim but I'm hoping to "clean up" the process still. – Jairaj Ranchod Jan 29 '21 at 17:52
  • I suspect the `.xls` files are still a different file type, but without the files themselves I wouldn't know for sure. If you haven't seen it already, see if this answer is useful: https://stackoverflow.com/a/27083260/6891484. Additionally, make sure the file isn't open when you are attempting to load it into R, as that seems to cause issues as well. – Justin Singh-M. Jan 29 '21 at 18:57

1 Answers1

-1

Check the below code, it works with library(readxl)

xls and xslx both work

enter image description here

CleanCoder
  • 332
  • 3
  • 14