Solved

Worksheet name too large?

Posted on 2014-01-03
2
289 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
Comment Utility
The maximum length of a worksheet name is 30 characters
0
 

Author Closing Comment

by:alastairwg1
Comment Utility
thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now