Question : A perl spreadsheet problem--reading from a  specific tab

Hi,

I have a problem. I want to read from the "Drivers" Tab only for the following Source.xls worksheet. How do I do that?

For the following code, it is being read from the "Calc" tab and hence printing out $serv value as 10040. Instead it should go to the Drivers tab and print out the $serv value as dd761c13n1

Where am I going wrong?

Is this assignment correct?

my $new_worksheet = $new_workbook->Worksheet("Drivers");
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
#!/usr/bin/perl5.10 -w



use warnings;
use Spreadsheet::WriteExcel::Big;
use Spreadsheet::ParseExcel;
use strict;
use IO::Scalar;
use Data::Dumper;

my $new_parser   = Spreadsheet::ParseExcel->new();
my $new_workbook = $new_parser->parse("/ms/user/s/sayantag/Source.xls");
my $new_worksheet = $new_workbook->Worksheet("Drivers");

my $calc = shift;

for  $new_worksheet ( $new_workbook->worksheets("Drivers") ) {
my ( $row_min, $row_max ) = $new_worksheet->row_range();
my ( $col_min, $col_max ) = $new_worksheet->col_range();

 for my $row ( $row_min .. $row_max ) {##First for##
 for my $col ( $col_min .. $col_max ) {##Second for##
   my $cell = $new_worksheet->get_cell( $row, $col );
     if ($col==0 && $row !=0 && ($new_worksheet->get_cell($row, 0)->value =~  /($calc)/))  {
       $col++;
       my $serv = $new_worksheet->get_cell($row, $col)->value;
       print "\nPls login to the server : $serv\n";
       $col++;
       my $path = $new_worksheet->get_cell($row, $col)->value;
       my $path1 = $serv . $path;
       chdir($path1);
       $col++;
       my $cmd = $new_worksheet->get_cell($row, $col)->value;

`$cmd`;       

      }
     }
    }
  }
Attachments:
 
The attached spreadsheet to be read.
 

Answer : A perl spreadsheet problem--reading from a  specific tab

Line 14 should be the following. I have not used perl for this before and referenced the IBM site.

http://www.ibm.com/developerworks/linux/library/l-pexcel/index.html
1:
my $new_worksheet = $new_workbook->Worksheets("Drivers");
Random Solutions  
 
programming4us programming4us