Quantcast

Read shortcuts of MS Excel files through R

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Read shortcuts of MS Excel files through R

Santosh-14
Dear Rxperts,

Through Windows OS, I created shortcuts (paste as shortcut) to excel
spreadsheets ( with "xlsx" as the file extension). I wasn't able to read
the shortcuts through R and using "read" functions of "xlsx" package.

exf <- "a1.xlsx.lnk"

> read.xlsx(exf,1)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
stream, nor an OOXML stream
> read.xlsx2(exf,1)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
stream, nor an OOXML stream


Would truly appreciate your suggestions.

Regards,
Santosh

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Read shortcuts of MS Excel files through R

Sarah Goslee
Hi,

On Thu, Sep 26, 2013 at 4:54 PM, Santosh <[hidden email]> wrote:
> Dear Rxperts,
>
> Through Windows OS, I created shortcuts (paste as shortcut) to excel
> spreadsheets ( with "xlsx" as the file extension). I wasn't able to read
> the shortcuts through R and using "read" functions of "xlsx" package.

A shortcut isn't an Excel file: it's the operating system that figures
that out. The shortcut itself is just a note to Windows with a file
reference in it. I wouldn't expect R to be able to parse that
reference.

Sarah


> exf <- "a1.xlsx.lnk"
>
>> read.xlsx(exf,1)
> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
>   java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
> stream, nor an OOXML stream
>> read.xlsx2(exf,1)
> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
>   java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
> stream, nor an OOXML stream
>
>
> Would truly appreciate your suggestions.
>
> Regards,
> Santosh
>


--
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Read shortcuts of MS Excel files through R

Marc Schwartz-3
Hi,

I am not on Windows so cannot test this, but a search reveals that in the R.utils CRAN package by Henrik Bengtsson, there is the readWindowsShortcut() function which may provide some assistance in getting the path to the actual file.

Thus:
   
  install.package("R.utils", dependencies = TRUE) # depends upon 'R.oo'
  require(R.utils)
  ?readWindowsShortcut


Regards,

Marc Schwartz


On Sep 26, 2013, at 5:05 PM, Sarah Goslee <[hidden email]> wrote:

> Hi,
>
> On Thu, Sep 26, 2013 at 4:54 PM, Santosh <[hidden email]> wrote:
>> Dear Rxperts,
>>
>> Through Windows OS, I created shortcuts (paste as shortcut) to excel
>> spreadsheets ( with "xlsx" as the file extension). I wasn't able to read
>> the shortcuts through R and using "read" functions of "xlsx" package.
>
> A shortcut isn't an Excel file: it's the operating system that figures
> that out. The shortcut itself is just a note to Windows with a file
> reference in it. I wouldn't expect R to be able to parse that
> reference.
>
> Sarah
>
>
>> exf <- "a1.xlsx.lnk"
>>
>>> read.xlsx(exf,1)
>> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
>>  java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
>> stream, nor an OOXML stream
>>> read.xlsx2(exf,1)
>> Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
>>  java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
>> stream, nor an OOXML stream
>>
>>
>> Would truly appreciate your suggestions.
>>
>> Regards,
>> Santosh
>>
>
>
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Read shortcuts of MS Excel files through R

Mark Lamias
In reply to this post by Santosh-14
Assuming you are trying to read the contents of the Excel files and not the shortcut itself, try something link this:

#C:\users\mark\desktop\A1.xlsx.lnk is a shortcut I created on my desktop to an xlsx document in another directory
#The windows type command, along with find gets the path to the actual file from the shortcut
cmd<-'type c:\\users\\mark\\desktop\\A1.xlsx.lnk|find "\\"|findstr/b "[a-z]:[\\\\]'
XLFileName<-shell(cmd, intern=T)
read.xlsx(XLFileName, 1)

I hope this helps.


--Mark J. Lamias



________________________________
 From: Santosh <[hidden email]>
To: r-help <[hidden email]>
Sent: Thursday, September 26, 2013 4:54 PM
Subject: [R] Read shortcuts of MS Excel files through R


Dear Rxperts,

Through Windows OS, I created shortcuts (paste as shortcut) to excel
spreadsheets ( with "xlsx" as the file extension). I wasn't able to read
the shortcuts through R and using "read" functions of "xlsx" package.

exf <- "a1.xlsx.lnk"

> read.xlsx(exf,1)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
stream, nor an OOXML stream
> read.xlsx2(exf,1)
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  :
  java.lang.IllegalArgumentException: Your InputStream was neither an OLE2
stream, nor an OOXML stream


Would truly appreciate your suggestions.

Regards,
Santosh

    [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...