Here's the code I've used to append to a spreadsheet. This was pretty straightforward other than finding the first row to add to and stopping the Excel process.

This spreadsheet has a border around all the cells. The Excel COM object treats this as being "in use". This means you've got to get the value of the cell "in use". If it's $null, then I know there's no text in it. When I went to close the COM object, excel.exe would never stop. This is why you see three different ways of killing it off; the Quit() method, releasing the COM object and finally I just kill the process completely.

$excel_file_path = 'C:\ChangeLog.xlsx'

## Instantiate the COM object
$Excel = New-Object -ComObject Excel.Application
$ExcelWorkBook = $Excel.Workbooks.Open($excel_file_path)
$ExcelWorkSheet = $Excel.WorkSheets.item("sheet1")

## Find the first row where the first 7 columns are empty
$row = ($ExcelWorkSheet.UsedRange.Rows | ? { ($_.Value2 | ? {$_ -eq $null}).Count -eq 7 } | select -first 1).Row
$ExcelWorkSheet.Cells.Item($row,1) = 'COLUMN 1 Text'
$ExcelWorkSheet.Cells.Item($row,2) = 'COLUMN 2 Text'
$ExcelWorkSheet.Cells.Item($row,3) = 'COLUMN 3 Text'
$ExcelWorkSheet.Cells.Item($row,4) = 'COLUMN 4 Text'
$ExcelWorkSheet.Cells.Item($row,5) = 'COLUMN 5 Text' 
Stop-Process -Name EXCEL -Force

Join the Jar Tippers on Patreon

It takes a lot of time to write detailed blog posts like this one. In a single-income family, this blog is one way I depend on to keep the lights on. I'd be eternally grateful if you could become a Patreon patron today!

Become a Patron!