ImportExcel icon indicating copy to clipboard operation
ImportExcel copied to clipboard

Conditional Formatting

Open Gtoml opened this issue 3 years ago • 0 comments

Loving this module. Have just starting looking into conditional formatting. I have successfully applied conditional formatting to a cell in column L if it has a value of NO. How can I apply that formatting to the entire row? I know I can add the range, but that will look for the value in the entire range. I only want the row highlighted if column L is NO.

Gtoml avatar Aug 08 '22 14:08 Gtoml

Sorry, missed this.

$data = ConvertFrom-Csv @"
Region,State,Units,Price
West,Texas,927,923.71
North,Tennessee,466,770.67
East,Florida,520,458.68
East,Maine,828,661.24
West,Virginia,465,053.58
North,Missouri,436,235.67
South,Kansas,214,992.47
North,North Dakota,789,640.72
South,Delaware,712,508.55
"@

$xlfile = 'test.xlsx'
Remove-Item $xlfile -ErrorAction SilentlyContinue

$excel = $data | Export-Excel $xlfile -AutoSize -PassThru

Add-ConditionalFormatting -Worksheet $excel.sheet1 -Range "A2:D10" -ConditionValue '=$A2="North"' -RuleType Expression -BackgroundColor LightGreen

Close-ExcelPackage $excel -Show

image

dfinke avatar Aug 27 '22 16:08 dfinke