Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: rowspan vals in Excel SS are not interpreted by ParseExcel::Simple

by misterperl (Pilgrim)
on Feb 09, 2017 at 13:57 UTC ( [id://1181525]=note: print w/replies, xml ) Need Help??


in reply to Re: rowspan vals in Excel SS are not interpreted by ParseExcel::Simple
in thread rowspan vals in Excel SS are not interpreted by ParseExcel::Simple

Thank You, great example! From the hints here I wrote this short solution (using the non-simple ParseExcel) :
# fill in merged cells my $ma = $page->{sheet}->{MergedArea}; for my $a ( @$ma ) { my ( $tr, $lc, $br, $rc ) = @$a; # propogate values top left to bottom right my $p = $page->{sheet}->{Cells}->[$tr]->[$lc]->{Val}; for ( my $row=$tr; $row<=$br; $row++ ) { for ( my $col=$lc; $col<=$rc; $col++ ) { $page->{sheet}->{Cells}->[$row]->[$col]->{Val}=$p; } } } # for $a
Seems to do the trick! I've seen some cases where the cell hash also has another Val which is something like _Val. I was never sure why those were there but I've seen examples where it contains the actual val. So in that case, $p may have to be assigned differently... Thanks all. I was floundering until you pointed out all the "merged" stuff. Seems like an odd term- I would have thought they'd use "span" not "merge"..
  • Comment on Re^2: rowspan vals in Excel SS are not interpreted by ParseExcel::Simple
  • Download Code

Replies are listed 'Best First'.
Re^3: rowspan vals in Excel SS are not interpreted by ParseExcel::Simple
by FreeBeerReekingMonk (Deacon) on Feb 09, 2017 at 20:09 UTC
    Ah, when I was reading the code, I found this explanation about Val and _Value in ~/perl5/lib/perl5/Spreadsheet/ParseExcel/Cell.pm

    ############################################################ # # value() # # Returns the formatted value of the cell. # sub value { my $self = shift; return $self->{_Value}; } ############################################################ # # unformatted() # # Returns the unformatted value of the cell. # sub unformatted { my $self = shift; return $self->{Val}; } ############################################################

    You see, sometimes a cell has a formula, and it holds the formula string, but also a resulting value. So Val holds =sum(A1+1) and _Value holds "42". It was/is? a problem in a XLS writer module, where only one was filled in, so you were required to open the spreadsheet in excel, let it calculate the values, then save it again in order to keep on processing the sheet.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1181525]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-18 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found