fix: corrected the script to include sheet name, and to add '=' in the ConditionValue

This commit is contained in:
Kinga Kazala
2022-07-13 09:26:00 +02:00
parent b92ea56fe9
commit 087feedde6

View File

@@ -1,10 +1,13 @@
try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return}
$xlSourcefile = "$env:TEMP\ImportExcelExample.xlsx"
# This example is using Excel generated by Highlight-DiffCells.ps1
# The displayed rule should be the same as in the PS script
$xlSourcefile = "$env:TEMP.\GetConditionalFormatting.xlsx"
$excel = Open-ExcelPackage -Path $xlSourcefile
$excel.Workbook.Worksheets | ForEach-Object {
$wsNme= $_.Name
$_.ConditionalFormatting | ForEach-Object {
Write-Host "Add-ConditionalFormatting -Worksheet `$excel[""$worksheetName""] -Range '$($_.Address)' -ConditionValue '$($_.Formula)' -RuleType $($_.Type) "
"Add-ConditionalFormatting -Worksheet `$excel[""$wsNme""] -Range '$($_.Address)' -ConditionValue '=$($_.Formula)' -RuleType $($_.Type) "
}
}