[R-gregmisc-users] SF.net SVN: r-gregmisc:[1874] trunk/gdata/inst/perl
Brought to you by:
warnes
From: <wa...@us...> - 2014-08-28 01:50:55
|
Revision: 1874 http://sourceforge.net/p/r-gregmisc/code/1874 Author: warnes Date: 2014-08-28 01:50:46 +0000 (Thu, 28 Aug 2014) Log Message: ----------- Modify code to use latest version of Spreadsheet::ParseExcel and to replace Spreadsheet::XLSX woth Spreadsheet::ParseXLSX Modified Paths: -------------- trunk/gdata/inst/perl/module_tools.pl trunk/gdata/inst/perl/sheetCount.pl trunk/gdata/inst/perl/xls2csv.pl Modified: trunk/gdata/inst/perl/module_tools.pl =================================================================== --- trunk/gdata/inst/perl/module_tools.pl 2014-08-28 01:28:23 UTC (rev 1873) +++ trunk/gdata/inst/perl/module_tools.pl 2014-08-28 01:50:46 UTC (rev 1874) @@ -37,9 +37,9 @@ }; eval { - require Spreadsheet::XLSX; + require Spreadsheet::ParseXLSX; $HAS_Spreadsheet_XLSX=1; - print "Loaded Spreadsheet::XLSX\n" if $VERBOSE; + print "Loaded Spreadsheet::ParseXLSX\n" if $VERBOSE; }; if($VERBOSE) @@ -48,7 +48,7 @@ if !$HAS_Spreadsheet_ParseExcel; print "ERROR: Unable to load Compress::Raw::Zlib perl module! \n" if ! $HAS_Compress_Raw_Zlib; - print "ERROR: Unable to load Spreadsheet::XLSX perl module! \n" + print "ERROR: Unable to load Spreadsheet::ParseXLSX perl module! \n" if ! $HAS_Spreadsheet_XLSX; } @@ -69,7 +69,7 @@ warn("WARNING: Perl module Compress::Raw::Zlib cannot be loaded.\n"); $HAS_Spreadsheet_XLSX or - warn("WARNING: Perl module Spreadsheet::XLSX cannot be loaded.\n"); + warn("WARNING: Perl module Spreadsheet::ParseXLSX cannot be loaded.\n"); ($HAS_Compress_Raw_Zlib && $HAS_Spreadsheet_XLSX ) or warn("WARNING: Microsoft Excel 2007 'XLSX' formatted files will not be processed.\n"); @@ -98,7 +98,7 @@ #return 0; # install the libraries we want - for $mod (qw( Compress::Raw::Zlib Spreadsheet::XLSX )){ + for $mod (qw( Compress::Raw::Zlib Spreadsheet::ParseXLSX )){ my $obj = CPAN::Shell->expand('Module',$mod); $obj->install; } Modified: trunk/gdata/inst/perl/sheetCount.pl =================================================================== --- trunk/gdata/inst/perl/sheetCount.pl 2014-08-28 01:28:23 UTC (rev 1873) +++ trunk/gdata/inst/perl/sheetCount.pl 2014-08-28 01:50:46 UTC (rev 1874) @@ -24,7 +24,7 @@ my($row, $col, $sheet, $cell, $usage, $filename, $volume, $directories, $whoami, $basename, $sheetnumber, $filename, - $text); + $text, $parser); ## @@ -78,15 +78,18 @@ my $oBook; ## First try as a Excel 2007+ 'xml' file +## First try as a Excel 2007+ 'xml' file eval { local $SIG{__WARN__} = sub {}; - $oBook = Spreadsheet::XLSX -> new ($ARGV[0]); + $parser = Spreadsheet::ParseXLSX -> new(); + $oBook = $parser->parse ($ARGV[0]); }; ## Then Excel 97-2004 Format -if($@) +if ( !defined $oBook ) { - $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \ + $parser = Spreadsheet::ParseExcel -> new(); + $oBook = $parser->parse($ARGV[0]) or \ die "Error parsing file '$ARGV[0]'.\n"; } Modified: trunk/gdata/inst/perl/xls2csv.pl =================================================================== --- trunk/gdata/inst/perl/xls2csv.pl 2014-08-28 01:28:23 UTC (rev 1873) +++ trunk/gdata/inst/perl/xls2csv.pl 2014-08-28 01:50:46 UTC (rev 1874) @@ -8,7 +8,7 @@ use strict; #use Spreadsheet::ParseExcel; -#use Spreadsheet::XLSX; +#use Spreadsheet::ParseXLSX; use POSIX; use File::Spec::Functions; use Getopt::Std; @@ -28,7 +28,9 @@ $targetfile,$basename, $sheetnumber, $filename, $volume, $directories, $whoami, $sep, $sepName, $sepLabel, $sepExt, - $skipBlankLines, %switches); + $skipBlankLines, %switches, + $parser, $oBook +); ## ## Figure out whether I'm called as xls2csv.pl or xls2tab.pl @@ -143,12 +145,14 @@ eval { local $SIG{__WARN__} = sub {}; - $oBook = Spreadsheet::XLSX -> new ($ARGV[0]); + $parser = Spreadsheet::ParseXLSX -> new(); + $oBook = $parser->parse ($ARGV[0]); }; ## Then Excel 97-2004 Format -if($@) +if ( !defined $oBook ) { - $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \ + $parser = Spreadsheet::ParseExcel -> new(); + $oBook = $parser->parse($ARGV[0]) or \ die "Error parsing file '$ARGV[0]'.\n"; } print "Done.\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |