mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Added conditional type for lt, le, gt, ge
This commit is contained in:
27
Examples/Charts/TextComparisons.ps1
Normal file
27
Examples/Charts/TextComparisons.ps1
Normal 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
|
||||
)
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user