Skip to content

Preserve worksheet part identities when sorting - #640

Open
JimmyLiuJia wants to merge 1 commit into
dhatim:masterfrom
JimmyLiuJia:fix/sorted-worksheet-part-identity
Open

JimmyLiuJia wants to merge 1 commit into
dhatim:masterfrom
JimmyLiuJia:fix/sorted-worksheet-part-identity

Conversation

@JimmyLiuJia

Copy link
Copy Markdown

Sorting worksheets after one or more sheets have been finished can attach a worksheet name to another sheet's cells, tab color and comments. A mix of finished and unfinished sheets can also create duplicate ZIP parts, producing an unreadable workbook.

Assign each worksheet a stable part index when it is created, and use its current tab position for the active tab and worksheet-scoped defined names. Add POI round-trip regressions for zero, one and all three sheets finished before sorting, checking sheet order and content, colors, comments, active sheet, repeating titles, autofilters and local named ranges.

Fixes #533.

Validation:

  • Reproduced the finish-before-sort scenario from Sorting Workbook with sortWorksheets is not reordinging colors #533's comment using the same three sheet names, colors and values; the original source misassigned sheet content, and the patched source preserved it.
  • Two of the three new regression cases fail against the original source; all three pass with the fix.
  • mvn -B -ntp clean verify jacoco:report on JDK 11: 203 tests, zero failures, errors or skips.

AI disclosure: OpenAI Codex assisted with the implementation and tests. The validation results above were obtained locally.

This branch has not been deployed

No deployments
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.

Sorting Workbook with sortWorksheets is not reordinging colors

1 participant