Author Posts

November 13, 2017 at 12:37 am

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

November 13, 2017 at 10:55 am

Try

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

November 13, 2017 at 11:24 am

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"