0
votes

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

1
Depending on what .xls version was used, it might actually be a .xml. See: github.com/tidyverse/readxl/issues/635#issuecomment-734504530 - Justin Singh-M.
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
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.
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
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: 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.

1 Answers

0
votes

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

xls and xslx both work

enter image description here