Skip to content

fix(sheet): stop reordering sheets a partial write never touched - #1235

Open
Sean-Walker0 wants to merge 1 commit into
apache:mainfrom
Sean-Walker0:fix/template-subset-sheet-order
Open

Sean-Walker0 wants to merge 1 commit into
apache:mainfrom
Sean-Walker0:fix/template-subset-sheet-order

Conversation

@Sean-Walker0

Copy link
Copy Markdown
Contributor

Purpose of the pull request

WriteSheetWorkbookWriteHandler sorts every sheet this write initialized by sheet number — regardless of how many sheets the workbook actually has. Filling a single sheet of a multi-sheet template therefore moved the written sheet ahead of sheets this write never touched:

template tabs [T0, T1];  fill only T1  ->  output tabs [T1, T0]

A template author's tab order is silently changed by a subset fill (the standard withTemplate(...).sheet("T1").doFill(...) flow), and the same applies to any partial write. Probed end-to-end on current main before this change.

No issue exists for this yet; found while auditing the write handler chain.

What's changed?

The handler now reorders only when this write initialized every sheet of the workbook. Multi-sheet writes keep their by-sheet-number sorting (the feature's purpose, introduced for writing sheets out of order); partial writes leave sheets they never touched in the author's order.

Checklist

  • I have read the Contributor Guide.
  • I have written the necessary doc or comment.
  • I have added the necessary unit tests and all cases have passed.

Verifying this change

WriteSheetOrderTest (both directions):

  • fillingASingleTemplateSheetKeepsTheTemplateTabOrder — red before (expected: <[T0, T1]> but was: <[T1, T0]>), green after;

  • writingEverySheetStillSortsBySheetNo — writes sheetNo 1 first, then 0, and pins that the full-write sorting still applies; green before and after.

  • ./mvnw clean package -B -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet: 1120 tests, 0 failures, 0 errors.

  • ./mvnw -pl fesod-sheet spotless:check: clean.

Notes

  • Behavior change is scoped to partial writes: output tab order now matches the input tab order for sheets the write did not initialize. Full-workbook writes are unchanged.
  • The handler is original to this fork's lineage (no EasyExcel upstream counterpart), so there is no upstream-parity question here.
  • Orthogonal to open PRs: no open PR touches WriteSheetWorkbookWriteHandler.

@Sean-Walker0
Sean-Walker0 force-pushed the fix/template-subset-sheet-order branch 2 times, most recently from cfa69e7 to 3c6f52d Compare October 29, 2026 22:52
@Sean-Walker0
Sean-Walker0 force-pushed the fix/template-subset-sheet-order branch 4 times, most recently from 6c39113 to 7463ba5 Compare November 11, 2026 11:29
WriteSheetWorkbookWriteHandler sorts every initialized sheet of the
write by sheet number, regardless of how many sheets the workbook
has. Filling a single sheet of a multi-sheet template therefore moved
the written sheet ahead of sheets this write never touched: a
template with tabs [T0, T1], filling only T1, produced [T1, T0].

Reorder only when the write initialized every sheet of the workbook,
which keeps the by-sheet-number sorting for multi-sheet writes while
leaving untouched template sheets in the author's order.

Verified with WriteSheetOrderTest (the subset-fill case reorders to
[T1, T0] before the change and keeps [T0, T1] after; the write-all
case pins the sorting behavior on both sides) plus the full
fesod-sheet suite (1120 tests) and spotless:check.
@Sean-Walker0
Sean-Walker0 force-pushed the fix/template-subset-sheet-order branch from 7463ba5 to 056407e Compare November 23, 2026 07:40

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.

1 participant