[R] Excel-Export

Marc Schwartz marc_schwartz at me.com
Mon Nov 23 16:45:42 CET 2009


On Nov 23, 2009, at 7:02 AM, koj wrote:

>
> Dear all,
>
> i use the following package/syntax to export data to excel:
>
> library(xlsReadWrite)
> write.xls( exportdata,pfad,colNames = TRUE,sheet = 1,from =  
> 1,rowNames =
> FALSE )
>
> Everything is fine, but the format of the export is not the best. For
> example, I every time have to adjust the column width. Furthermore  
> there is
> no possibility to highlight some cell or make them colourful.
>
> I create a lot of such outputs and I want to have the sheets in a  
> nicer
> format to make them better readable, especially for the people, who  
> works
> with my files.
>
> Have you any suggestions to reach this target? Ideally I can do this  
> within
> R and not in a second step via a VBA-Makro or something like this.  
> Is there
> a possibility in R, e. g. with a package?
>
> I have the same problem with the package xtable for export to Latex.
>
> I am very happy about the packages, but it would be perfect, if I  
> can adjust
> some things in this direction. Probably there are somes ways for a  
> solution.
> I am very glad about references.
>
> Thank you very much in advance,
>
> Jens.

The ability to adjust columns widths in a predictable fashion is not  
easy to implement outside of Excel (or an equivalent application). The  
Auto-fit function in Excel, for example, is a run-time only feature,  
which means that Excel must be available and running.

The problem is that assumptions have to be made as to the cell content  
on a per column basis, including the font and font formatting being  
used and is not guaranteed to be accurate outside of Excel. I had  
looked at this for the WriteXLS package, but it is problematic.

With respect to the formatting of individual cells (colors, borders,  
etc.), you might want to look at the RDCOMClient package:

   http://www.omegahat.org/RDCOMClient/

See examples in the Introduction for that package.

HTH,

Marc Schwartz




More information about the R-help mailing list