Used poj's knowhow to make it work. (what was I thinking yesterday evening, AlignH is for indentation, not merged cells). Code is smaller to boot!

use Spreadsheet::ParseExcel::Simple; my $xls = Spreadsheet::ParseExcel::Simple->read('excel.xls'); foreach my $sheet ($xls->sheets) { #unmerge unmerge($sheet->{sheet}); while ($sheet->has_data) { my @data = $sheet->next_row; print join("\t", @data),"\n"; } } sub unmerge{ my($oWkS) =@_; print "--------- SHEETNAME:", $oWkS->{Name}, "\n"; my $range = $oWkS->get_merged_areas(); for (@$range){ print " start row : $_->[0] start col : $_->[1] end row : $_->[2] end col : $_->[3] \n\n"; $oWkC = $oWkS->{Cells}[$_->[0]][$_->[1]]; for my $iR ($_->[0] .. $_->[2]){ for my $iC ($_->[1] .. $_->[3]){ next if ($iR eq $_->[0] && $iC eq $_->[1]); print "SET [$iR][$iC] <= [$_->[0]][$_->[1]]\n"; $oWkS->{Cells}[$iR][$iC]->{_Value} = $oWkC->Value; } } } print "--------- DONE Unmerging.\n"; }

Output:

--------- SHEETNAME:Sheet1 start row : 0 start col : 0 end row : 2 end col : 0 SET [1][0] <= [0][0] SET [2][0] <= [0][0] --------- DONE Unmerging. cat Fluffy cat Vera cat Manxie

Caveat: The {_Value} is still not guaranteed to be in the topleft cell from a range (as misterperl had it in the second column), so the code might need to be expanded to first SEARCH for a defined {_Value} in the range. Then have that as the source data cell, then iterate over the range writing all other cells that are undefined...

You can access the functions from within Simple like:

$sheet->{sheet}->get_merged_areas();


In reply to Re^2: rowspan vals in Excel SS are not interpreted by ParseExcel::Simple by FreeBeerReekingMonk
in thread rowspan vals in Excel SS are not interpreted by ParseExcel::Simple by misterperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.