Skip to content

Fix Set-ExcelRow/Set-ExcelRange -Height affecting the next row (off-by-one) - #1746

Draft
dfinke with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-excel-row-height-issue
Draft

Fix Set-ExcelRow/Set-ExcelRange -Height affecting the next row (off-by-one)#1746
dfinke with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-excel-row-height-issue

Conversation

Copilot AI commented Aug 15, 2026

Copy link
Copy Markdown

Set-ExcelRow -Height and Set-ExcelRange -Height were applying the specified height to one extra row beyond the target range due to an off-by-one error in the row iteration bounds.

Root cause

In Set-ExcelRange.ps1, the row range was computed as:

# Before: generates Rows+1 values (e.g. row 1 → iterates 1..2)
($Range.Start.Row)..($Range.Start.Row + $Range.Rows)

Fix

# After: generates exactly Rows values
($Range.Start.Row)..($Range.Start.Row + $Range.Rows - 1)

Set-ExcelRow delegates height setting to Set-ExcelRange, so both commands are fixed by this single change. All other formatting properties were unaffected as they operate directly on the ExcelRange style, not through this manual row iteration.

Co-authored-by: dfinke <67258+dfinke@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Set-ExcelRow height modification for next row Fix Set-ExcelRow/Set-ExcelRange -Height affecting the next row (off-by-one) Aug 15, 2026
Copilot AI requested a review from dfinke August 15, 2026 23:27
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.

Set-ExcelRow -Height modifies the height of the next row as well

2 participants