[R] extract worksheet names from an Excel file

David Scott d.scott at auckland.ac.nz
Fri Jun 24 07:11:04 CEST 2011


  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



More information about the R-help mailing list