Skip to content

Instantly share code, notes, and snippets.

@Xachriel
Created March 17, 2013 12:22
Show Gist options
  • Save Xachriel/5181296 to your computer and use it in GitHub Desktop.
Save Xachriel/5181296 to your computer and use it in GitHub Desktop.
A stupid way of finding the number of sheets in a excel file
Nsheets = function(FILE){
FAILED = FALSE
i = 1
while(!FAILED){
test = try(read.xls(FILE, sheet=i), silent=TRUE)
if(class(test) == "try-error"){
stop(return(i-1))
}else{
i = i+1
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment