From 8f05e9d57d0d7b90143ff0820c9d3bdfe8feca1b Mon Sep 17 00:00:00 2001 From: dfinke Date: Mon, 29 Feb 2016 10:01:05 -0500 Subject: [PATCH] Added conditional type for lt, le, gt, ge --- Examples/Charts/TextComparisons.ps1 | 27 +++++++++++++++++++++++++++ Export-Excel.ps1 | 4 ++-- New-ConditionalText.ps1 | 1 + 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Examples/Charts/TextComparisons.ps1 diff --git a/Examples/Charts/TextComparisons.ps1 b/Examples/Charts/TextComparisons.ps1 new file mode 100644 index 0000000..78ccbb6 --- /dev/null +++ b/Examples/Charts/TextComparisons.ps1 @@ -0,0 +1,27 @@ +cls + +ipmo ..\..\ImportExcel.psd1 -Force + +$data = $( + New-PSItem 100 (echo test testx) + New-PSItem 200 + New-PSItem 300 + New-PSItem 400 + New-PSItem 500 +) + +$file1 = "tryComparison1.xlsx" +$file2 = "tryComparison2.xlsx" + +rm $file1 -ErrorAction Ignore +rm $file2 -ErrorAction Ignore + +$data | Export-Excel $file1 -Show -ConditionalText $( + New-ConditionalText -ConditionalType GreaterThan 300 + New-ConditionalText -ConditionalType LessThan 300 -BackgroundColor cyan +) + +$data | Export-Excel $file2 -Show -ConditionalText $( + New-ConditionalText -ConditionalType GreaterThanOrEqual 275 + New-ConditionalText -ConditionalType LessThanOrEqual 250 -BackgroundColor cyan +) diff --git a/Export-Excel.ps1 b/Export-Excel.ps1 index ebfbf2e..8716389 100644 --- a/Export-Excel.ps1 +++ b/Export-Excel.ps1 @@ -347,8 +347,8 @@ function Export-Excel { $rule=($ws.Cells[$Range].ConditionalFormatting).$target() - if($targetConditionalText.Text) { - if($targetConditionalText.ConditionalType -match "equal|notequal") { + if($targetConditionalText.Text) { + if($targetConditionalText.ConditionalType -match "equal|notequal|lessthan|lessthanorequal|greaterthan|greaterthanorequal") { $rule.Formula= $targetConditionalText.Text } else { $rule.Text = $targetConditionalText.Text diff --git a/New-ConditionalText.ps1 b/New-ConditionalText.ps1 index 7f1f41a..da0bd0c 100644 --- a/New-ConditionalText.ps1 +++ b/New-ConditionalText.ps1 @@ -7,6 +7,7 @@ function New-ConditionalText { [String]$Range, [OfficeOpenXml.Style.ExcelFillStyle]$PatternType=[OfficeOpenXml.Style.ExcelFillStyle]::Solid, [ValidateSet( + "LessThan","LessThanOrEqual","GreaterThan","GreaterThanOrEqual", "NotEqual","Equal","ContainsText","NotContainsText","BeginsWith","EndsWith", "Last7Days","LastMonth","LastWeek", "NextMonth","NextWeek",