Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^9: Reading Excel file in perl

by Athanasius (Chancellor)
on Nov 26, 2012 at 08:28 UTC ( #1005587=note: print w/replies, xml ) Need Help??

in reply to Re^8: Reading Excel file in perl
in thread Reading Excel file in perl

Hello Pauler,

I don’t really understand what this code is trying to do, so I’ll just offer some observations:

  1. The code as given does not compile. This line:

    print "OKAY: found the column as "class"\n";

    needs to be:

    print "OKAY: found the column as \"class\"\n";

    with the inner double-quote characters backslashed.

  2. You should always — yes, always! — begin each script with:

    use strict; use warnings;

    and never comment them out again!

  3. I suspect the script’s main problem is with the next statement on the 6th-last line. This ends the current iteration of the innermost loop, but as it’s the last statement within that loop, it currently does nothing. Perhaps you meant last? Or next LABEL; where LABEL refers back to a previous (i.e., outer) loop? See next and last in Perl documentation.

Hope that helps,

Athanasius <°(((><contra mundum

Replies are listed 'Best First'.
Re^10: Reading Excel file in perl
by Pauler (Initiate) on Dec 12, 2012 at 10:11 UTC
    Hi Guys , Thanks for all the help. I have got the solution for reading only 1 column value via perl.
    foreach my $sheet (@{$excel->{Worksheet}}) { printf("Sheet: %s\n", $sheet->{Name}); $sheet->{MaxRow} ||= $sheet->{MinRow}; $rowCnt = $sheet->{MinRow}; foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) { $sheet->{MaxCol} ||= $sheet->{MinCol}; $colCnt = $sheet->{MinCol}; foreach my $col ($sheet->{MinCol} .. $sheet->{MaxCol}) { my $cell = $sheet->{Cells}[$row][$col]->{Val}; if ( $cell eq "Column Heading" ) { $val_col=$col; print "OKAY: found column values as below\n"; my $res = $sheet->{Cells}[$rowCnt][$col]->{Val}; #Read +s each value for the column print $res, "\n"; next; } if ($val_col eq $col ) { print $cell, "\n"; push (@col_arr, $cell); } foreach $cell (@data){ print "into new loop\n"; } } } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005587]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-07-16 03:18 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (330 votes). Check out past polls.