Re: [R] how to export ".xls" file with colorful cells?

From: Marc Schwartz <>
Date: Thu, 24 Jul 2008 08:28:46 -0500

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:

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 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:

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:

This module would provide for platform independent creation and cell level formatting of Excel files.

HTH, Marc Schwartz mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 24 Jul 2008 - 13:31:34 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Jul 2008 - 14:32:13 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive