Error when writing to Excel files using the packages xlsx and xlsx2

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Error when writing to Excel files using the packages xlsx and xlsx2

syrvn
Dear group,

I am working on a rather big project where the output data frames have dimensions of 3000 x 15 or greater. We are using xlsx and xlsx2 to write the data.frames to Excel sheets.

Since recently we get the following error, when trying to write the data frames to the excel sheets:

Error in ls(envir = envir, all.names = private) :
  invalid 'envir' argument

We figured out that the error occurs when the excel sheet is open while R tries to write to it.
But now, closing all open excel sheets does not fix the error any longer. We also tried deleting the excel sheet in case it might be corrupt but we still get the same error.

We have a very narrow timeframe so any help on how to fix that error is very much appreciated.

Best regards,
Flo
Reply | Threaded
Open this post in threaded view
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

Denis Kazakiewicz
The most safe way work with excel is through .csv format

Sorry for being nonspecific
On 13.07.2011 12:46, syrvn wrote:

> Dear group,
>
> I am working on a rather big project where the output data frames have
> dimensions of 3000 x 15 or greater. We are using xlsx and xlsx2 to write the
> data.frames to Excel sheets.
>
> Since recently we get the following error, when trying to write the data
> frames to the excel sheets:
>
> Error in ls(envir = envir, all.names = private) :
>    invalid 'envir' argument
>
> We figured out that the error occurs when the excel sheet is open while R
> tries to write to it.
> But now, closing all open excel sheets does not fix the error any longer. We
> also tried deleting the excel sheet in case it might be corrupt but we still
> get the same error.
>
> We have a very narrow timeframe so any help on how to fix that error is very
> much appreciated.
>
> Best regards,
> Flo
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Error-when-writing-to-Excel-files-using-the-packages-xlsx-and-xlsx2-tp3664617p3664617.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

Denis Kazakiewicz
In reply to this post by syrvn
write.csv(mydata,  file="mydataExported.csv", na="")

On 13.07.2011 12:46, syrvn wrote:

> Dear group,
>
> I am working on a rather big project where the output data frames have
> dimensions of 3000 x 15 or greater. We are using xlsx and xlsx2 to write the
> data.frames to Excel sheets.
>
> Since recently we get the following error, when trying to write the data
> frames to the excel sheets:
>
> Error in ls(envir = envir, all.names = private) :
>    invalid 'envir' argument
>
> We figured out that the error occurs when the excel sheet is open while R
> tries to write to it.
> But now, closing all open excel sheets does not fix the error any longer. We
> also tried deleting the excel sheet in case it might be corrupt but we still
> get the same error.
>
> We have a very narrow timeframe so any help on how to fix that error is very
> much appreciated.
>
> Best regards,
> Flo
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Error-when-writing-to-Excel-files-using-the-packages-xlsx-and-xlsx2-tp3664617p3664617.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

syrvn
In reply to this post by Denis Kazakiewicz
Hi Denis,

are you saying that we should write the R output (data frame) to a .csv file and then import
it manually into Excel?

Thanks
Flo
Reply | Threaded
Open this post in threaded view
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

Gabor Grothendieck
In reply to this post by syrvn
On Wed, Jul 13, 2011 at 5:46 AM, syrvn <[hidden email]> wrote:

> Dear group,
>
> I am working on a rather big project where the output data frames have
> dimensions of 3000 x 15 or greater. We are using xlsx and xlsx2 to write the
> data.frames to Excel sheets.
>
> Since recently we get the following error, when trying to write the data
> frames to the excel sheets:
>
> Error in ls(envir = envir, all.names = private) :
>  invalid 'envir' argument
>
> We figured out that the error occurs when the excel sheet is open while R
> tries to write to it.
> But now, closing all open excel sheets does not fix the error any longer. We
> also tried deleting the excel sheet in case it might be corrupt but we still
> get the same error.
>
> We have a very narrow timeframe so any help on how to fix that error is very
> much appreciated.
>

There are quite a few approaches listed here:

http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[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
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

syrvn
Hi,

thanks for this web page!

We decided to go for XLConnect because it can read and write xlsx sheets.
With that package we get the same error message (see above) as with the xlsx package.

After that error we even end up with a corrupted excel spread sheet. We are not able
to open it any longer.

Because both packages use java as an interface we may conclude it is not an error in
the package itself but with java.

Any other advices?

Many thanks,
Flo
Reply | Threaded
Open this post in threaded view
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

David Winsemius

On Jul 13, 2011, at 9:14 AM, syrvn wrote:

> Hi,
>
> thanks for this web page!

Grothendieck had offered:
-----
There are quite a few approaches listed here:

http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows
-----
>
> We decided to go for XLConnect because it can read and write xlsx  
> sheets.
> With that package we get the same error message (see above) as with  
> the xlsx
> package.

There is no "above" in you current message. Most of us are _not_ using  
Nabble to read r-help postings.

>
> After that error we even end up with a corrupted excel spread sheet.  
> We are
> not able
> to open it any longer.
>
> Because both packages use java as an interface we may conclude it is  
> not an
> error in
> the package itself but with java.
>
> Any other advices?

Surely using two packages does not exhaust the advice on that page.

(... which you did not provide as context  ... what fraction of Nabble  
users _ever_ read the Posting Guide?)

In particular: The xls.write function in gdata uses Perl.

>



David Winsemius, MD
West Hartford, CT

______________________________________________
[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
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

David Winsemius

On Jul 13, 2011, at 11:49 AM, David Winsemius wrote:

>
>
>
> In particular: The xls.write function in gdata uses Perl.

Wrong name.... I was thinking of read.xls in gdata.

>

David Winsemius, MD
West Hartford, CT

______________________________________________
[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
|

Re: Error when writing to Excel files using the packages xlsx and xlsx2

zlatan24
This post has NOT been accepted by the mailing list yet.
In reply to this post by syrvn
excel recovery *.xls, *,xlt, *.xlsx, xlsm, *.xltm, *.xltx, *.xlam file formats. It finds out, scans and recovers corrupted excel file. Software launches under low system requirements, is compatible with Windows 98 and later.