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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: How to read merged cells from excel
by roboticus (Chancellor) on Sep 14, 2011 at 12:37 UTC

    asidnayak:

    Yes.

    Slightly more specifically, the very first example in Spreadsheet::ParseExcel is capable of reading merged cells:

    $ cat merge_925829.pl #!/usr/bin/perl use strict; use warnings; use Spreadsheet::ParseExcel; my $p = Spreadsheet::ParseExcel->new(); my $WB = $p->parse('merge_925829.xls'); if (!defined $WB) { die $p->error(), ".\n"; } for my $WS ($WB->worksheets()) { my ( $row_min, $row_max ) = $WS->row_range(); my ( $col_min, $col_max ) = $WS->col_range(); for my $row ( $row_min .. $row_max ) { for my $col ( $col_min .. $col_max ) { my $cell = $WS->get_cell( $row, $col ); next unless $cell; print "Row, Col = ($row, $col)\n"; print "Value = ", $cell->value(), "\n"; print "Unformatted = ", $cell->unformatted(), "\n"; print "\n"; } } } $ ./merge_925829.pl Row, Col = (0, 0) Value = a1/b1 Unformatted = a1/b1 Row, Col = (0, 1) Value = Unformatted = Row, Col = (0, 2) Value = c1 Unformatted = c1 Row, Col = (1, 0) Value = a2 Unformatted = a2 Row, Col = (1, 1) Value = b2/c2 Unformatted = b2/c2 Row, Col = (1, 2) Value = Unformatted = Row, Col = (2, 0) Value = a3/b3/c3 Unformatted = a3/b3/c3 Row, Col = (2, 1) Value = Unformatted = Row, Col = (2, 2) Value = Unformatted = Row, Col = (3, 0) Value = a4 Unformatted = a4 Row, Col = (3, 1) Value = b4 Unformatted = b4 Row, Col = (3, 2) Value = c4 Unformatted = c4

    Perhaps you ought to provide a little more detail with your question so you can get a more useful response...

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: How to read merged cells from excel
by blindluke (Hermit) on Sep 14, 2011 at 12:39 UTC

    If you want to read the contents of merged cells, treat them like a normal cell, just remember to supply the address of the upper-left cell of the merged range.

    If you don't know how to read any cells from an Excel spreadsheet file, look at the modules Spreadsheet::ParseExcel or Spreadsheet::XLSX, depending of the Excel version that you (or anyone who provided you the input data) is using.

    regards,
    Luke Jefferson