Added conditional type for lt, le, gt, ge

This commit is contained in:
dfinke
2016-02-29 10:01:05 -05:00
parent 5d449f91e6
commit 8f05e9d57d
3 changed files with 30 additions and 2 deletions

View File

@@ -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
)

View File

@@ -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

View File

@@ -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",