Reading comments from Excel file with PowerShell Reading comments from Excel file with PowerShell powershell powershell

Reading comments from Excel file with PowerShell


Each Comment Object has a Text method which returns or updates the information.

I took that a step further and split on the newline so you can separate out the comment from the author:

foreach ($comment in $comments) {    $CommentText = $comment.text().split([environment]::newline)    [pscustomobject]@{        'Author' = $CommentText[0]        'Text' = $CommentText[1]    }}


I'm sure there are a boatload of ways to get this done...

import-module psexcel$fred = new-object OfficeOpenXml.ExcelPackage -ArgumentList "C:\Users\mccarthyd\Documents\Book1.xlsx"foreach ($worksheet in $fred.Workbook.Worksheets) {    $worksheet.comments}

see this post: powershell excel access without installing Excel