Skip to content

Add configurable WrapText measurement to AutoFitColumns (#2427)#2428

Merged
swmal merged 4 commits into
develop8from
fix/WrappedTextAutofitMode
Jul 21, 2026
Merged

Add configurable WrapText measurement to AutoFitColumns (#2427)#2428
swmal merged 4 commits into
develop8from
fix/WrappedTextAutofitMode

Conversation

@swmal

@swmal swmal commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Implements #2427.
Adds a WrappedTextAutofitMode property to ExcelTextSettings, backed by a new eWrappedTextAutofitMode enum, giving control over how cells with WrapText enabled contribute to column width in AutoFitColumns().

Modes:

Skip — wrapped cells are ignored during autofit (default; preserves current behaviour).
FullText — the entire cell text is measured as a single line.
SplitNewLine — split on explicit line breaks (CR, LF, CRLF); widest line drives the width.
SplitWord — split on whitespace (space, tab, line breaks) and hyphens (U+002D, U+2010); widest segment drives the width. Visible hyphens are included in the segment width, whitespace is not.

Changes:

New eWrappedTextAutofitMode enum and WrappedTextAutofitMode property on ExcelTextSettings, propagated to the measurer.
Reworked MeasureTextInternal to measure per segment; the widest segment determines the result.
Fixed a pre-existing bug where East Asian character width accumulated across all lines instead of resetting per line.
Deprecated the internal MeasureWrappedTextCells flag via [Obsolete], mapping to the new enum.

Tests: Added coverage for all four modes plus CRLF handling, widest-segment-first, hyphen-as-visible-boundary, and the East Asian per-line reset.

Notes:

Applies to the generic font-metrics measurer; the System.Drawing measurer currently ignores the setting (to be addressed before the next release).
MeasureWrappedTextCells removal and the ITextMeasurer interface cleanup are deferred to EPPlus 9.

@swmal
swmal merged commit 70384af into develop8 Jul 21, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this to Pending Release in Epplus Enhancements Jul 21, 2026
@swmal
swmal deleted the fix/WrappedTextAutofitMode branch July 21, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Pending Release

Development

Successfully merging this pull request may close these issues.

3 participants