Is it possible to trim a excel cell like this:
<newline>
<newline>
A
B
C
<newline>
<newline>
to:
A
B
C
I tried it with the COM Object:
$excel = New-Object -ComObject Excel.Application
$wb = $excel.Workbooks.Open($path)
foreach ($ws in $wb.Worksheets){
[void]$ws.Cells.Trim()
}
But Trim()
is not a valid method. Is there any other way to Trim excel cell(s) for a complete worksheet or a given range ($ws.Range)
?