Skip to content
Prev 181704 / 398502 Next

Re ad & name multiple excel sheets using RODBC

simeon duckworth wrote:
In Microsoft theory, something like the below should be ok (note the $), but
never managed to get this to work. The same method works perfectly when you
have name ranges within a spreadsheet.

If you only have the sheet names, you should use package xlsReadWrite which
is rather fast, but has some limitations in the non-commercial version.

Dieter


library(RODBC)
filepath <- "workbook.xlsx"
tabls  = list()
channel <- odbcConnectExcel2007(filepath)
for (i in 1:2)
  tabls[[i]] =  sqlQuery(channel, paste("SELECT * from
[Tabelle",i,"$]",sep=""))
odbcClose(channel) # I prefer an explicit odbcClose, but generic close.RODBC
should work.