Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Reading merged cells using Spreadsheet::XLSX

by digitaldhoom (Initiate)
on Nov 02, 2012 at 01:59 UTC ( [id://1001899]=perlquestion: print w/replies, xml ) Need Help??

digitaldhoom has asked for the wisdom of the Perl Monks concerning the following question:

I am using the Spreadsheet::XLSX module to parse a sheet with some cells merged in column B across rows. I am using a for loop to get the value in column A and B for each row:

for my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) { my $A_cell = $sheet->{Cells}[$row][$A_col]; my $B_cell = $sheet->{Cells}[$row][$B_col]; my $A_val = $A_cell->{Val}; my $B_val = $B_cell->{Val}; ...

(I have already gotten the indices for $A_col and $B_col.) The cells in column A are never merged, and I need to get its corresponding value in column B.

===|===| A1 |B1 | ===|===| A2 |B2 | ===| | A3 | | ===|===| A4 |B4 | ===|===|

However, if it is a merged cell in B, then only the first row shows the value and not the subsequent ones of the cell. I tried storing the previous value and use that if it is merged by checking with the is_merged() function as shown in the Spreadsheet::ParseExcel module:

 my $is_merged = $B_cell->is_merged();

I get the following error though: "Can't call method "is_merged" on an undefined value" Is the is_merged() function not in the XLSX version, or am I doing something wrong? Thanks.

Replies are listed 'Best First'.
Re: Reading merged cells using Spreadsheet::XLSX
by Anonymous Monk on Nov 02, 2012 at 03:11 UTC

    You don't have an object, $B_cells is not defined

    $ perl -e " undef->is_merged " Can't call method "is_merged" on an undefined value at -e line 1.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-19 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found