I'd like to be able to read multiple sheets from an excel workbook and use
the sheet name to name the resulting dataframe using RODBC.  at the moment
i've figured out how to do it the long way (see below) but feel sure that
there is a speedier & possibly automatic way to do it in R.  i've tried to
run a loop using sqlTables but it seemed to break the connection.  unless
i've missed something, i cant see a solution to this on the help list.

grateful for any help or pointers

simeon

# long way
library(RODBC)
filepath <- "C:/Data/workbook.xlsx"
connect <- odbcConnectExcel2007(filepath)
tbls <- sqlTables(connect)
sheet1 <-sqlFetch(channel=connect,sqtable='sheet1')
sheet2 <-sqlFetch(channel=connect,sqtable='sheet2')
sheet3 <-sqlFetch(channel=connect,sqtable='sheet3')
.. etc
close(connect)

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to