Skip to content

fix(sheet): give head-row handler contexts their real row index - #1234

Open
Sean-Walker0 wants to merge 1 commit into
apache:mainfrom
Sean-Walker0:fix/head-row-handler-index
Open

Sean-Walker0 wants to merge 1 commit into
apache:mainfrom
Sean-Walker0:fix/head-row-handler-index

Conversation

@Sean-Walker0

Copy link
Copy Markdown
Contributor

Purpose of the pull request

When writing a multi-row head, WriteContextImpl.initHead created the RowWriteHandlerContext for every head row with the same starting row index instead of the loop's row index. A two-row head reported rowIndex=0 twice (while relativeRowIndex correctly said 0 then 1), a three-row head reported 0 three times, and so on. Any RowWriteHandler (or code reached from one) that keys on getRowIndex() — custom position checks, per-row styling, writing markers or comments at computed positions — saw wrong indexes for every head row after the first. Data-row contexts were already correct.

Observed with a registered handler on a 2-row-head write (default settings):

rowIndex=0 relative=0 isHead=true   firstCell=c0r0
rowIndex=0 relative=1 isHead=true   firstCell=c0r1   <-- should be 1
rowIndex=2 relative=0 isHead=false  firstCell=v0
rowIndex=3 relative=1 isHead=false  firstCell=w1

No issue exists for this yet; found while probing handler context values.

What's changed?

The context is now created with the loop's row index i instead of the constant newRowIndex — one line. The physical rows themselves were always written at i (WorkBookUtil.createRow(sheet, i)), so handlers now see the index of the row they are actually observing.

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

  • HeadRowHandlerContextTest — red before (head rows must report their physical row indexes ==> expected: <[0, 1]> but was: <[0, 0]>), green after; data rows 2 and 3 are pinned on both sides.
  • WriteHandlerTest (the handler call-matrix suite): 23/23 unchanged.
  • ./mvnw clean package -B -Dmaven.test.skip=false -pl fesod-common,fesod-shaded,fesod-sheet: 1119 tests, 0 failures, 0 errors.
  • ./mvnw -pl fesod-sheet spotless:check: clean.

Notes

@Sean-Walker0
Sean-Walker0 force-pushed the fix/head-row-handler-index branch 2 times, most recently from 1f02d86 to 5b663be Compare October 29, 2026 22:52
@Sean-Walker0
Sean-Walker0 force-pushed the fix/head-row-handler-index branch 4 times, most recently from 175b2ee to ab31a8e Compare November 11, 2026 11:27
initHead created the row handler context for every head row with the
same starting row index instead of the loop's row index, so for a
multi-row head all head rows reported the first head row's index
(a two-row head reported rowIndex=0 twice while relativeRowIndex said
0 then 1). Any RowWriteHandler that keys on getRowIndex() - custom
position checks, per-row styling, marker writes - saw wrong indexes
for every head row after the first. Data-row contexts were already
correct.

Pass the loop's row index.

Verified with HeadRowHandlerContextTest (head rows report [0, 0]
before the change and [0, 1] after; data rows 2 and 3 pinned on both
sides), the unchanged WriteHandlerTest call-matrix suite, the full
fesod-sheet suite (1119 tests) and spotless:check.
@Sean-Walker0
Sean-Walker0 force-pushed the fix/head-row-handler-index branch from ab31a8e to 004d6df Compare November 23, 2026 07:38

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