mirror of
https://github.com/dfinke/ImportExcel.git
synced 2025-12-06 00:23:20 +00:00
Get-ConditionalFormatting function added
This commit is contained in:
@@ -2,12 +2,20 @@
|
||||
|
||||
# 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) "
|
||||
function Get-ConditionalFormatting {
|
||||
param (
|
||||
[string] $xlSourcefile
|
||||
)
|
||||
$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) "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$xlSourcefile = "$env:TEMP.\GetConditionalFormatting.xlsx"
|
||||
Get-ConditionalFormatting -xlSourcefile $xlSourcefile
|
||||
Reference in New Issue
Block a user