in reply to Spreadsheet::ParseXLSX question on merged cells

Spreadsheet::ParseXLSX claims to provide Spreadsheet::ParseExcel::Cell objects, which should have an is_merged method.
  • Comment on Re: Spreadsheet::ParseXLSX question on merged cells

Replies are listed 'Best First'.
Re^2: Spreadsheet::ParseXLSX question on merged cells
by chafelix (Acolyte) on Nov 13, 2025 at 19:50 UTC

    Thanks, I tried it. Could not really find examples of it being used.

    use Spreadsheet::ParseXLSX; use Spreadsheet::ParseXLSX::Cell; my $parser = Spreadsheet::ParseXLSX->new( ); my $workbook = $parser->parse($infile); print "workbook=$workbook\n"; my ( $row_min, $row_max ) = $worksheet->row_range(); my ( $col_min, $col_max ) = $worksheet->col_range(); for my $worksheet ( $workbook->worksheets() ) { my $cell = $worksheet->{Cells}[$row_min][$col_min] ; print Dumper($cell); my $toprint= $cell->is_merged() ? 'got merged' : 'unmerged'; print "$toprint\n"; }

    prints $VAR1 = undef;

    Can't call method "is_merged" on an undefined value at

    So unless I am doing something wrong, there is no Merged or is_Merged property

      Not all cells are going to be populated, and ones that don't will be undef, as you are seeing, not a cell object. Try it on a specific cell that you know has content. Or better yet, one you know is merged and one you know has content but is not merged.

        That is the problem. I want to say "if the cell in the col_min has no content (!$val) and is merged, then do A, else do B

        If I try:

        my $ans=$cell->is_merged()

        I get Can't call method "is_merged" on an undefined value