Add configurable WrapText measurement to AutoFitColumns (#2427)#2428
Open
swmal wants to merge 2 commits into
Open
Add configurable WrapText measurement to AutoFitColumns (#2427)#2428swmal wants to merge 2 commits into
swmal wants to merge 2 commits into
Conversation
…surement in AutoFitColumns; fix per-line East Asian width reset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #2427.
Adds a
WrappedTextAutofitMode property toExcelTextSettings, backed by a neweWrappedTextAutofitModeenum, giving control over how cells withWrapTextenabled contribute to column width inAutoFitColumns().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
eWrappedTextAutofitModeenum andWrappedTextAutofitModeproperty onExcelTextSettings, propagated to the measurer.Reworked
MeasureTextInternalto 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
MeasureWrappedTextCellsflag 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).
MeasureWrappedTextCellsremoval and theITextMeasurerinterface cleanup are deferred to EPPlus 9.