--- fudge9 2012-10-08 01:48:45.046875000 -0700 +++ fudge10 2012-10-08 02:23:20.609375000 -0700 @@ -53,74 +53,13 @@ ###This points to the folder where the excel files are placed my $workfile = "C:/Users/McLovin/Documents/Thesis/Datatal/" . "$usefile"; print "$workfile\n"; - my $Book = $Excel->Workbooks->Open($workfile); - - my $sheetcnt = $Book->Worksheets->Count(); -#~ foreach my $r ( 1 .. $sheetcnt ) { - { - my $Sheet = $Book->Worksheets( 1 ); - push @recID, $Sheet->{Name}; - print "Worksheet name is $Sheet->{Name}\n"; - my $Tot_Rows = $Sheet->UsedRange->Rows->{'Count'}; - my $Tot_Cols = $Sheet->UsedRange->Columns->{'Count'}; - my $firstCol = eval { $Sheet->Cells( 1, 1)->{'Value'} }; - - if( defined $firstCol and $firstCol =~ /^\d{10}$/ ) - { - push @right, $firstCol; - push @legal, $firstCol; - push @prod, $firstCol; - - ValueTargetCols( - $Sheet, - [ \@right, \@legal, \@prod, ], - [ 1 .. $Tot_Rows ], - [ qw{ 4 5 } ], - ); - ValueTargetCols( - $Sheet, - [ \@legal, ], - [ 1 .. $Tot_Rows ], - [ qw{ 6 } ], - ); - ValueTargetCols( - $Sheet, - [ \@right, ], - [ 1 .. $Tot_Rows ], - [ qw{ 7 8 9 } ], + BlahBlahNameHere( + $Excel, + $workfile, + \@recID, \@right, \@legal, \@prod, ); - - ValueTargetCols( - $Sheet, - [ \@right, \@legal, ], - [ 1 .. $Tot_Rows ], - [ qw{ 10 11 } ], - ); - - ValueTargetCols( - $Sheet, - [ \@prod, \@right, ], - [ 1 .. $Tot_Rows ], - [ qw{ 12 } ], - ); - - ValueTargetCols( - $Sheet, - [ \@prod ], - [ 1 .. $Tot_Rows ], - [ qw{ - 13 14 15 - 17 18 - 20 21 22 23 24 25 26 27 - 32 33 34 35 36 37 38 39 - } ], - ); - - } - } - $Book->Close; } ################################################################################ @@ -351,4 +290,78 @@ } return; } + + + +sub BlahBlahNameHere { + my( $Excel, $workfile, $recID, $right, $legal, $prod ) = @_; + my $Book = $Excel->Workbooks->Open($workfile); + + my $sheetcnt = $Book->Worksheets->Count(); +#~ foreach my $r ( 1 .. $sheetcnt ) { + { + my $Sheet = $Book->Worksheets( 1 ); + push @$recID, $Sheet->{Name}; + print "Worksheet name is $Sheet->{Name}\n"; + my $Tot_Rows = $Sheet->UsedRange->Rows->{'Count'}; + my $Tot_Cols = $Sheet->UsedRange->Columns->{'Count'}; + my $firstCol = eval { $Sheet->Cells( 1, 1)->{'Value'} }; + + if( defined $firstCol and $firstCol =~ /^\d{10}$/ ) + { + push @$right, $firstCol; + push @$legal, $firstCol; + push @$prod, $firstCol; + + ValueTargetCols( + $Sheet, + [ $right, $legal, $prod, ], + [ 1 .. $Tot_Rows ], + [ qw{ 4 5 } ], + ); + + ValueTargetCols( + $Sheet, + [ $legal, ], + [ 1 .. $Tot_Rows ], + [ qw{ 6 } ], + ); + + ValueTargetCols( + $Sheet, + [ $right, ], + [ 1 .. $Tot_Rows ], + [ qw{ 7 8 9 } ], + ); + + ValueTargetCols( + $Sheet, + [ $right, $legal, ], + [ 1 .. $Tot_Rows ], + [ qw{ 10 11 } ], + ); + + ValueTargetCols( + $Sheet, + [ $prod, $right, ], + [ 1 .. $Tot_Rows ], + [ qw{ 12 } ], + ); + + ValueTargetCols( + $Sheet, + [ $prod ], + [ 1 .. $Tot_Rows ], + [ qw{ + 13 14 15 + 17 18 + 20 21 22 23 24 25 26 27 + 32 33 34 35 36 37 38 39 + } ], + ); + + } + } + $Book->Close; +} __END__