[R] how to export ".xls" file with colorful cells?
Marc Schwartz
marc_schwartz at comcast.net
Thu Jul 24 15:28:46 CEST 2008
on 07/23/2008 08:29 PM XinMeng wrote:
> Hi all: I wanna know how to expoort ".xls" file. And in the exported
> ".xls" file, how to set different cells with different color?
>
> Thanks a lot! My best.
You don't indicate what operating system you are using and that is
important as most of the relevant R packages/functions are Windows specific.
If you are on Windows, then you might want to look at the xlsReadWrite
CRAN package to address the basic process of creating Excel files. More
information is available via the R Wiki here:
http://wiki.r-project.org/rwiki/doku.php?id=tips:data-io:ms_windows
The being said, a quick review suggests that the packages do not offer
any cell level formatting functions.
If you are looking to create formatted reports, I would urge you to
consider looking at using R's Sweave package, which uses LaTeX to enable
reproducible research. An alternative would be the odfWeave package,
which enables you to create OpenOffice.org documents that can also then
be saved as MS Office documents or printed to PDF files. For some ideas
of how Sweave can be used, go here:
http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/StatReport
If you must stay with Excel (eg. job requires it) and want to automate
such operations, and further, might be comfortable coding in Perl, you
can look at the Spreadsheet::WriteExcel module on CPAN:
http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm
This module would provide for platform independent creation and cell
level formatting of Excel files.
HTH,
Marc Schwartz
More information about the R-help
mailing list