Hi list, Is there a R function I can use to extract the worksheet names from an Excel file?? If no, any other automatic ways (not using R) to do this? thanks! ...Tao
Bill.Venables at csiro.au
2011-Jun-24 04:55 UTC
[R] extract worksheet names from an Excel file
Package XLConnect appears to provide this kind of thing. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Shi, Tao Sent: Friday, 24 June 2011 2:42 PM To: r-help at r-project.org Subject: [R] extract worksheet names from an Excel file Hi list, Is there a R function I can use to extract the worksheet names from an Excel file?? If no, any other automatic ways (not using R) to do this? thanks! ...Tao ______________________________________________ R-help at 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.
On 24/06/11 16:55, Bill.Venables at csiro.au wrote:> Package XLConnect appears to provide this kind of thing. > > -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Shi, Tao > Sent: Friday, 24 June 2011 2:42 PM > To: r-help at r-project.org > Subject: [R] extract worksheet names from an Excel file > > Hi list, > > Is there a R function I can use to extract the worksheet names from an Excel file? If no, any other automatic ways (not using R) to do this? > > thanks! > > ...Tao > > > ______________________________________________ > R-help at 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. > > ______________________________________________ > R-help at 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.If you use RODBC to connect to an xls or xlsx file you can use sqlTables to show not only the worksheet names, but the presence of any named data ranges. Sample code from a student exercise: require(RODBC) channel <- odbcConnectExcel("bikesWithDate.xls") sqlTables(channel) David -- _________________________________________________________________ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142, NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.scott at auckland.ac.nz, Fax: +64 9 373 7018
On Fri, Jun 24, 2011 at 12:41 AM, Shi, Tao <shidaxia at yahoo.com> wrote:> Hi list, > > Is there a R function I can use to extract the worksheet names from an Excel file?? If no, any other automatic ways (not using R) to do this? > > thanks! >Many or all of the Excel interfaces listed here: http://rwiki.sciviews.org/doku.php?id=tips:data-io:ms_windows&s=excel can do that but be careful since one or more the packages listed there always returns the sheet names sorted in alphabetical order which means that you can't tell which is the first sheet, which is the second, etc. (if that is important). gdata has a specific function to do it: library(gdata) sheetNames("myfile.xls") -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com