ImportExcel
ImportExcel copied to clipboard
Formatting weirdness when adding rows to a table
Start with an Excel table that looks like this:
If you try to add two more rows to the table using
$newrows = @(
[PSCustomObject]@{
A=10
B=11
C=12
},
[PSCustomObject]@{
A=20
B=21
C=22
}
)
$newrows | Export-Excel -Path (Join-Path -Path $PSScriptRoot -ChildPath 'modified2.xlsx') -WorksheetName 'Sheet1' -Table 'Table1' -Append
You'll get a new formatting for the extended table:
Removing the -Table 'Table1' parameter preserves the formatting:
Code, input file and output files in: