Skip to content

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

@szeder

Description

@szeder

When using Set-ExcelRow or Set-ExcelRange to set the height of a row, the height of the next row is modified as well.

Steps to reproduce the issue:

$Data = ConvertFrom-Csv @"
A,B,C
1,2,3
4,5,6
7,8,9
10,11,12
13,14,15
16,17,18
"@

$XlPkg = $Data | Export-Excel -WorksheetName TestHeight -TableStyle None -PassThru

Set-ExcelRow -Worksheet $XlPkg.TestHeight -Row 1 -Height 42 -WrapText -VerticalAlignment Top -HorizontalAlignment Center -Bold -Italic -Underline
Set-ExcelRange -Worksheet $XlPkg.TestHeight -Range '4:5' -Height 32 -WrapText -VerticalAlignment Top -HorizontalAlignment Center -Bold -Italic -Underline

foreach ($r in 1..$XlPkg.TestHeight.Dimension.Rows) { $XlPkg.TestHeight.Row($r).Height }

The output of the loop in the last line is:

42
42
15
32
32
32
15

The resulting Excel file looks like this:
Image

I would have expected that only the height of row 1 is set to 42, and only the height of rows 4 and 5 are set to 32, while the height of the other rows remains unchanged (i.e. the default 15).

What happens instead is that the height of rows 1 and 2 are set to 42, and the height of rows 4, 5 and 6 are set to 32.

Setting all those other formating properties is not necessary to trigger this issue. I've only specified those options to demonstrate that they seem to behave as expected, i.e. they affect only the given rows. Only the -Height "overflows" into the next row.
Set-ExcelColumn -Width seems to be working as expected as well.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions