fix: synchronize ColumnLookup when splitting multi-column ranges (#2471) - #2472
Closed
lievendf wants to merge 1 commit into
Closed
fix: synchronize ColumnLookup when splitting multi-column ranges (#2471)#2472lievendf wants to merge 1 commit into
lievendf wants to merge 1 commit into
Conversation
…tware#2471) - Call ColumnLookup.UpdateColumn when column bounds are truncated during range splitting in ExcelWorksheet and ExcelStyles. - Use GetValueInner instead of GetColumn in SetStyleInner to prevent recursive column span fragmentation. - Add unit test MultiColumnStyle_WhenSplitBySubRange_ShouldInheritStyle. Fixes EPPlusSoftware#2471
Contributor
|
Thanks for this PR! However, even though this fix works the core problem here is that the styleId is set before the ExcelColumn is written to the cell store. This causes the style to be written to the old ExcelColumn object. With this fix not UpdateColumn calls are needed as these are done in the SetValueInner method. I'll add credit to your in the release note for this. |
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.
Fixes #2471
Summary
When applying style or format changes to a sub-range (e.g.
B:C) inside a previously styled multi-column range (e.g.A:J), the truncated column span (e.g.D:J) updatesColumnMaxin the column object, butColumnLookupis not notified of the updated boundary key. Subsequent cell style lookups beyond columnCfailTryGetExcelColumnboundary checks and incorrectly fall back to default style 0 (11pt font). Furthermore, callingGetColumninsideSetStyleInnercaused recursive span fragmentation across adjacent columns.Changes
ColumnLookup: CallColumnLookup.UpdateColumn(column.ColumnMin, column)whenevercolumn.ColumnMaxorcolumn._columnMaxis modified during range splitting inExcelWorksheet.csandExcelStyles.cs.GetColumn(col)withGetValueInner(0, col) as ExcelColumninsideSetStyleInnerinExcelWorksheet.cs.MultiColumnStyle_WhenSplitBySubRange_ShouldInheritStyleinExcelStyleTests.cs.