Add comments to Excel cell

This topic contains 2 replies, has 2 voices, and was last updated by  James May 1 week ago.

  • Author
    Posts
  • #84073

    James May
    Participant

    I need to write a comment in a cell if it contains the word "family" (for now as it will point to an array) – however, I have no idea how to do it.
    This is what i have so far (i used PSEXCEL, but if anyone has any other ideas (this will run on a server however – no excel installed)

    ## https://github.com/RamblingCookieMonster/PSExcel
    Import-Module "\\path\to\PSExcel"
    $k = Search-CellValue -Path "C:\test.xlsx" { $_ -like 'family'}
    if ($k.worksheetname -ne $null){
    #knowing that i have a good sheet, i can get the row, column and write a comment, but i don't know how to do it
    }
    

    I have a basic excel file like so (called it "text.xlsx")
    group
    family
    test1
    test23
    tedsfgsd
    sdfsd
    sdrfsd
    sdfssd
    sdfasd
    sdftsd
    sdhfsdf
    sdf

  • #84115

    Simon B
    Participant

    Try

    [void] $CurrentSheet.Cells.Item($ServerRow+1,$ServerCol).Addcomment("comment")

  • #84118

    James May
    Participant

    tried that one and received a "You cannot call a method on a null-valued expression." (in my case the $CurrentSheet was set either static or dynamic ie. $CurrentSheet = $k.WorksheetName and/or $CurrentSheet = "Sheet1"

You must be logged in to reply to this topic.