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

I am using Spreadsheet:Parsexlsx to read an excel file. I need to say "if this is a merged cell, then...."

I used ptkdb to see what attributes there are. So each cell has

-Col and Row ( numbers)

-Format with keys (AlignH,AlignV, BdrColor, BdrDiag,Bdrstyle)

-Fill (an array)

-FmtIdx (a number)

-Font (another hash ref)

-FontNo

-Hiden

-a number of Ignores

-FormatNo

-Rich

-Sheet

-Type

_Val and value

-Lock

-Rotate

-Shrink

-Wrap, (all these numbers)

The problem is none of these seem to have the info I need. Any ideas?

  • Comment on Spreadsheet::ParseXLSX question on merged cells

Replies are listed 'Best First'.
Re: Spreadsheet::ParseXLSX question on merged cells
by ysth (Canon) on Nov 13, 2025 at 02:01 UTC
    Spreadsheet::ParseXLSX claims to provide Spreadsheet::ParseExcel::Cell objects, which should have an is_merged method.

      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.
Re: Spreadsheet::ParseXLSX question on merged cells
by starX (Chaplain) on Nov 14, 2025 at 16:58 UTC

    important to note that merged ranges are stored at the worksheet level, not on a per cell basis. You can get a merged range with my @mergedRange = $worksheet->get_merged_areas(); which will give you the four coordinates defining the merged range in the form of ($start_row, $start_col, $end_row, $end_col).

    Important to note that the data will only be stored in top left cell of a merged range, so if the cell is in the merged range, you would be able to access its data at $start_row, $start_col