Files
ImportExcel/Examples/ConditionalFormatting/GetConditionalFormatting.ps1

14 lines
590 B
PowerShell

try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return}
# 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 {
"Add-ConditionalFormatting -Worksheet `$excel[""$wsNme""] -Range '$($_.Address)' -ConditionValue '=$($_.Formula)' -RuleType $($_.Type) "
}
}