Skip to content

Fix GetMinMergedCell for cells spanning all columns and multiple rows#359

Open
th-joerger wants to merge 1 commit intoempira:masterfrom
th-joerger:feature/fixTableMergeAllColumnsBug-#358
Open

Fix GetMinMergedCell for cells spanning all columns and multiple rows#359
th-joerger wants to merge 1 commit intoempira:masterfrom
th-joerger:feature/fixTableMergeAllColumnsBug-#358

Conversation

@th-joerger
Copy link
Copy Markdown

@th-joerger th-joerger commented Apr 23, 2026

Fixes #358

When a single cell spans all columns (MergeRight = columnCount - 1) and more than one row (MergeDown >= 1), GetMinMergedCell() throws InvalidOperationException because the condition

resultRowIndex + cell.MergeDown == row

simplifies to MergeDown == 0, which the origin cell (MergeDown >= 1) does not satisfy. All other cells in that row are excluded because they are not in _mergedCells (they are covered by the merge).

Fix: add a fallback loop that finds the cell with the minimum MergeDown value in _mergedCells for the given row. This matches the behaviour of GetMinMergedCellOriginal() which handles this case correctly.

When a single cell spans all columns (MergeRight = columnCount - 1) and
more than one row (MergeDown >= 1), GetMinMergedCell() throws
InvalidOperationException because the condition

    resultRowIndex + cell.MergeDown == row

simplifies to MergeDown == 0, which the origin cell (MergeDown >= 1) does
not satisfy. All other cells in that row are excluded because they are not
in _mergedCells (they are covered by the merge).

Fix: add a fallback loop that finds the cell with the minimum MergeDown
value in _mergedCells for the given row. This matches the behaviour of
GetMinMergedCellOriginal() which handles this case correctly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetMinMergedCell wirft Exception wenn eine Zelle alle Spalten und mehrere Zeilen überspannt

1 participant