ImportExcel icon indicating copy to clipboard operation
ImportExcel copied to clipboard

How to do conditional formatting in this example

Open Sambsamb opened this issue 9 years ago • 0 comments

Hey Doug, Great module by the way. I'm trying to do conditional formatting for cells that do not match a couple of values. Something like: if ($value -notmatch 'aaa' -and $value -notmatch 'bbb') { use this format... }

I tried: Remove-Item -Path $OutputFile -ErrorAction SilentlyContinue $FinalResult | Export-Excel -Path $OutputFile -Show -ConditionalText $( New-ConditionalText -ConditionalType NotContainsText $NTPServers[0].IPv4Address DarkRed LightPink New-ConditionalText $NTPServers[0].IPv4Address Blue Cyan New-ConditionalText $NTPServers[1].IPv4Address Blue Cyan ) -AutoSize -FreezeTopRowFirstColumn

where $NTPServers[0].IPv4Address and $NTPServers[1].IPv4Address are the 2 values that I'm referring to, but this makes everything other than $NTPServers[0].IPv4Address red/pink..

any advise?

Also, can you post an example of using -Range with New-ConditionalText?

Sambsamb avatar Jun 28 '17 13:06 Sambsamb