Update Export-Excel.ps1

Fixed problem with conditional formatting code that was breaking in Powershell 3
This commit is contained in:
headsphere
2016-09-21 13:22:57 +01:00
committed by GitHub
parent 23967f7738
commit 27dea78413

View File

@@ -78,7 +78,7 @@ function Export-Excel {
foreach($format in $ConditionalFormat ) {
$target = "Add$($format.Formatter)"
$rule = ($ws.ConditionalFormatting).$target($format.Range, $format.IconType)
$rule = ($ws.ConditionalFormatting).PSObject.Methods[$target].Invoke($format.Address, $format.IconType)
$rule.Reverse = $format.Reverse
}
@@ -392,7 +392,7 @@ function Export-Excel {
$Range=$targetConditionalText.Range
if(!$Range) { $Range=$ws.Dimension.Address }
$rule=($ws.Cells[$Range].ConditionalFormatting).$target()
$rule=($ws.Cells[$Range].ConditionalFormatting).PSObject.Methods[$target].Invoke()
if($targetConditionalText.Text) {
if($targetConditionalText.ConditionalType -match "equal|notequal|lessthan|lessthanorequal|greaterthan|greaterthanorequal") {