[R-gregmisc-users] SF.net SVN: r-gregmisc:[1377] trunk/gdata/inst/perl
Brought to you by:
warnes
From: <wa...@us...> - 2010-01-23 02:30:15
|
Revision: 1377 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1377&view=rev Author: warnes Date: 2010-01-23 02:30:09 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Add perl scripts to extract worksheet names and sheet count from Excel files Added Paths: ----------- trunk/gdata/inst/perl/sheetCount.pl trunk/gdata/inst/perl/sheetNames.pl Added: trunk/gdata/inst/perl/sheetCount.pl =================================================================== --- trunk/gdata/inst/perl/sheetCount.pl (rev 0) +++ trunk/gdata/inst/perl/sheetCount.pl 2010-01-23 02:30:09 UTC (rev 1377) @@ -0,0 +1,49 @@ +#!/usr/bin/perl + +BEGIN { +use File::Basename; +unshift(@INC, dirname $0); +} + +use strict; +use Spreadsheet::ParseExcel; + +# declare some varibles local +my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename); + +## +## Usage information +## +$usage = <<EOF; + +sheetCount.pl <excel file> + +Output is the number of sheets in the excel file. + +EOF + +## +## parse arguments +## + +if(!defined($ARGV[0])) + { + print $usage; + exit 1; + } + +my $fileName=$ARGV[0]; + +## +## open spreadsheet +## + +my $oExcel = new Spreadsheet::ParseExcel; + +open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n"; +close(FH); + +my $oBook = $oExcel->Parse($fileName); + +print $oBook->{SheetCount} , "\n"; + Added: trunk/gdata/inst/perl/sheetNames.pl =================================================================== --- trunk/gdata/inst/perl/sheetNames.pl (rev 0) +++ trunk/gdata/inst/perl/sheetNames.pl 2010-01-23 02:30:09 UTC (rev 1377) @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +BEGIN { +use File::Basename; +unshift(@INC, dirname $0); +} + +use strict; +use Spreadsheet::ParseExcel; + +# declare some varibles local +my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename); + +## +## Usage information +## +$usage = <<EOF; + +sheetCount.pl <excel file> + +Output is the number of sheets in the excel file. + +EOF + +## +## parse arguments +## + +if(!defined($ARGV[0])) + { + print $usage; + exit 1; + } + +my $fileName=$ARGV[0]; + +## +## open spreadsheet +## + +my $oExcel = new Spreadsheet::ParseExcel; + +open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n"; +close(FH); + +my $oBook = $oExcel->Parse($fileName); + +## Get list all worksheets in the file +my @sheetlist = (@{$oBook->{Worksheet}}); + +foreach my $sheet (@sheetlist) +{ + print "\"$sheet->{Name}\" "; +} + +print "\n"; + Property changes on: trunk/gdata/inst/perl/sheetNames.pl ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |