3

I've used RODBC for some time to import Excel spreadsheets with mostly good results. However I have had no luck writing to an Excel spreadsheet. Also are there favorable differences using the xlsx format with Excel2007?

kpierce8
  • 15,977
  • 2
  • 23
  • 25

5 Answers5

6

I've used the technique described here: Export Data Frames To Multi-worksheet Excel File

Galwegian
  • 41,475
  • 16
  • 112
  • 158
3

XLConnect works well. It is cross-platform. It can read and write xls and xlsx files. See this previous answer

Community
  • 1
  • 1
Jeromy Anglim
  • 33,939
  • 30
  • 115
  • 173
3

The R Data Import/Export manual should be considered the best source of advice for these questions.

For reading you can indeed use the RODBC package. An easier solutoion may be read.xls() from the gdata

For writing you can use one of the wrapper packages such as WriteXLS which wraps around Perl libraries that know how to write in the proprietary and not formally documented xls format.

In general, xlsx will not be a solution as this format is newer, once again proprietary and not documented. For that reason there are even fewer tools coping with this.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • 1
    xlsx is an open format (though probably complicated) http://msdn.microsoft.com/en-us/library/dd922181.aspx You can actually unzip an xlsx file and view the xml. I expect this will result eventually in a good read/write solution. – kpierce8 Dec 04 '09 at 19:08
  • 1
    I see. Well, so you have the need for a new `write.xlsx()` function, and the know-how. So go off now and scratch that itch :) – Dirk Eddelbuettel Dec 04 '09 at 22:29
  • The manual leaves out something pretty important: http://stackoverflow.com/questions/6099243/read-an-excel-file-directly-from-a-r-script/26265428#26265428 – russellpierce Oct 08 '14 at 20:21
2

This question is 3 years old, but I'll throw this in: if you want to write to the spreadsheet, remember to add readOnly=FALSE as an argument to odbcConnectExcel and odbcConnectExcel2007.

Hong Ooi
  • 56,353
  • 13
  • 134
  • 187
0

There is a package that may help with dealing with excel 2007, but I haven't tried it.

http://www.omegahat.org/RExcelXML/

Robert
  • 838
  • 6
  • 8