Solved

Worksheet name too large?

Posted on 2014-01-03
2
300 Views
Last Modified: 2014-01-03
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
0
Comment
Question by:alastairwg1
2 Comments
 
LVL 6

Accepted Solution

by:
ButlerTechnology earned 500 total points
ID: 39753563
The maximum length of a worksheet name is 30 characters
0
 

Author Closing Comment

by:alastairwg1
ID: 39753682
thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question