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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |