[Rd] xlsReadWrite Pro and embedding objects and files in Excel worksheets

tshort tshort at eprisolutions.com
Thu Feb 8 20:09:15 CET 2007


Another option for creating XLS files it to write out HTML instead. Excel can
read html files just fine, and a useful trick is giving the html file a .xls
extension. So, from the user's point of view, it is an excel file even
though it's just an html file. 

Using html works great for embedding links and formatted tables. You can use
the R2HTML package to generate HTML files, including formatting for a large
number of R objects.

One thing you can't do with this approach is include graphics. In theory you
could do that by extending this approach. Excel can read in *.mhtml files,
which are multipart mime-encoded bundles that include the html file plus
mime-encoded graphics files that go with it. You could generate png files in
R to include. Excel will also happily read in mhtml files with a .xls
extension. The following links could help you get started:

http://en.wikipedia.org/wiki/MHTML
http://finzi.psych.upenn.edu/R/library/caTools/html/base64.html

I don't know of an R package that has a function to encode files as a
multipart mime, but the link above is a good start.

- Tom

Tom Short
EPRI


Mark W Kimpel wrote:
> 
> Hans-Peter and other R developers,
> 
> How are you? Have you made any progess with embedding Url's in Excel?
> 
> Well, I have been busy thinking of more things for you to do;)
> 
> My colleagues in the lab are not R literate, and some are barely 
> computer literate, so I give them everything in Excel workbooks. I have 
> gradually evolved a system such that these workbooks have become 
> compendia of my data, output, and methods. That, in fact, is why I 
> bought the Pro version of xlsReadWritePro. I have been saving graphics 
> as PDF files, then inserting them as object in Excel sheets.
> 
> What I would like to be able to do is to embed objects (files) in sheets 
> of a workbook directly from within R. I would also like to be able to 
> save my current R workspace as an object embedded in a sheet so that in 
> the future, if packages change, I could go back and recreate the 
> analysis. I do not need to be able to manuipulate files that R has not 
> created, like a PDF file from another user. I would, however, like to be 
> able to save my graphics as PDF files inside a worksheet, even if it 
> meant creating a  temp file or something.
> 
> Before people begin talking about how MySQL or some other database could 
> handle all that archiving, let me say that that is not what my 
> colleagues want. They want a nice Excel file that they can take home on 
> there laptops. One thing I like about worksheets is that they themselves 
> can contain many embedded files, so it keeps our virtual desks neater 
> and less confusing.
> 
> Hans, if you could do this, it would be of tremendous benefit to me and 
> hopefully a lot of people. R developers tend to think that all 
> scientists are running Linux on 64-bit computers, but most biomedical 
> researches still store date in Excel files. This won't solve everybody's 
> needs, but it could be a start.
> 
> Well, let me know what you think. I am cc'ing R-devel to see if any of 
> those guys have ideas as well.
> 
> Thanks,
> Mark
> 
> 
> 
> -- 
> Mark W. Kimpel MD
> Neuroinformatics
> Department of Psychiatry
> Indiana University School of Medicine
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 

-- 
View this message in context: http://www.nabble.com/xlsReadWrite-Pro-and-embedding-objects-and-files-in-Excel-worksheets-tf3191737.html#a8871790
Sent from the R devel mailing list archive at Nabble.com.



More information about the R-devel mailing list