ClosedXML / ClosedXML/ClosedXML

AdjustToContents() does not adjust row height with a merged and wrapped row

Open
#2,387 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
5.7k
Forks
933
Avg merge
12h 14m
Merged PRs (30d)
1

Description

## Read and complete the full issue template

Do not randomly delete sections. They are here for a reason.

**Do you want to request a *feature* or report a *bug*?**
- [x] Bug
- [ ] Feature
- [ ] Question

**Did you test against the latest CI build?**
- [x ] Yes
- [ ] No

If you answered `No`, please test with [the latest development build](https://ci.appveyor.com/project/ClosedXML/ClosedXML/branch/develop/artifacts) first.

**Version of ClosedXML**

e.g. 0.102.3

**What is the current behavior?**

When attempting to set auto adjust row height for a row which has merged cells and wrap text=true, row height does not change

**What is the expected behavior or new feature?**

Row height should adjust to the content of the merged/wrapped row

**Is this a regression from the previous version?**

not a regression

## Reproducibility
**This is an important section. Read it carefully. Failure to do so will cause a 'RTFM' comment.**

Without a code sample, it is unlikely that your issue will get attention. Don't be lazy. Do the effort and assist the developers to reproduce your problem. Code samples should be [minimal complete and verifiable](https://stackoverflow.com/help/mcve). Sample spreadsheets should be attached whenever applicable. Remove sensitive information.

**Code to reproduce problem:**
```vb
oSheet.Range("A3:E3").Merge()
oSheet.Range("A3:E3").Style.Alignment.SetWrapText(True)
oSheet.Range("A3:E3").Value = "A teenage gunman shot and injured a teacher and a student, and fatally injured another student at his former elementary school, before throwing down his jammed weapon to call his grandparents. Prior to the school attack, the gunman shot and killed his father at his residence."
oSheet.Range("A3:E3").Style.Alignment.SetVertical(XLAlignmentVerticalValues.Top)
oSheet.Range("A3:E3").Style.Alignment.SetHorizontal(XLAlignmentHorizontalValues.Left)
oSheet.Rows(3).AdjustToContents()

```

- [x] I attached a sample spreadsheet. (You can drag files on to this issue)
[RCRS-Catalog-Search-Results.xlsx](https://github.com/user-attachments/files/16753585/RCRS-Catalog-Search-Results.xlsx)

Contributor guide

Open the contributing guide

Research direction

Start with the AdjustToContents() entry point and reproduce the issue using the merged, wrapped A3:E3 example in the report. Trace how merged cells and wrapped text are handled during row-height calculation, then verify that the row height reflects the content while preserving the reported alignment behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.