Link to home
Start Free TrialLog in
Avatar of alastairwg1
alastairwg1

asked on

Worksheet name too large?

I am new to perl and I am running a code to read in .xls files and combine them into a text file. The data was in Pdf, but I have converted then to .xls files using a pdf converter. Unfortunately it tries to put the worksheet name from the filename, so in an example the filename is VendorPS000102_INV1451879_PS000102inv0000066067_001451879s_20120709.xls and the worksheet name is VendorPS000102_INV1451879_PS000. The error I get is

"use of initialised value $iPTN2 in bitwise and (&)( at C:/perl/site/lib/spreadsheet/ParseExcel.pm line 1521"

If I change the worksheet name to Fred, it works fine. The program is:-


while ((length(@flist[$count]) > 0))
      { $filename =@flist[$count];
            if (substr($filename,length($filename)-4,3) eq "xls" )  
            {
      $filename =  substr(@flist[$count],0,length(@flist[$count])-1) ;
 
    my $parser   = Spreadsheet::ParseExcel->new();
    my $workbook = $parser->parse($filename);

    die $parser->error(), ".\n" if ( !defined $workbook );

    # Following block is used to Iterate through all worksheets
    # in the workbook and print the worksheet content
    #for my $worksheet ( $workbook->worksheets(1) ) {
             foreach my $sheet (0 .. $sheet  - 1) {

        # Find out the worksheet ranges
        my ( $row_min, $row_max ) = $sheet->row_range();
        my ( $col_min, $col_max ) = $sheet->col_range();

        for my $row ( $row_min .. $row_max ) {
            @line =($row,"|",$filename, "|",$sheet->{Name},"|");
            for my $col ( $col_min .. $col_max ) {

                # Return the cell object at $row and $col
                my $cell = $sheet->get_cell( $row, $col );
                 if ($cell) {
            
       push (@line , "|",$cell->unformatted());
      }
        else
           {
        push (@line , "|");
           }
                  }
                  print GH @line ,"\n";
                        }
                  }
            } $count++;
      }

I would be grateful of any help.

Cheers

Alastair
ASKER CERTIFIED SOLUTION
Avatar of ButlerTechnology
ButlerTechnology

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of alastairwg1
alastairwg1

ASKER

thanks