-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1341 from dfinke/DoNotShowValues-for-Conditional
Add -ShowOnlyIcon to New-ConditionalFormattingIconSet. Base on https:…
- Loading branch information
Showing
7 changed files
with
110 additions
and
13 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
Examples/ConditionalFormatting/ConditionalFormattingIcontSetOnlyIcon.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
try { Import-Module $PSScriptRoot\..\..\ImportExcel.psd1 } catch { throw ; return } | ||
|
||
$data = ConvertFrom-Csv @" | ||
Region,State,Other,Units,Price,InStock | ||
West,Texas,1,927,923.71,1 | ||
North,Tennessee,3,466,770.67,0 | ||
East,Florida,0,1520,458.68,1 | ||
East,Maine,1,1828,661.24,0 | ||
West,Virginia,1,465,053.58,1 | ||
North,Missouri,1,436,235.67,1 | ||
South,Kansas,0,214,992.47,1 | ||
North,North Dakota,1,789,640.72,0 | ||
South,Delaware,-1,712,508.55,1 | ||
"@ | ||
|
||
$xlfile = "$PSScriptRoot\test.xlsx" | ||
Remove-Item $xlfile -ErrorAction SilentlyContinue | ||
|
||
$cfi1 = New-ConditionalFormattingIconSet -Range C:C -ConditionalFormat ThreeIconSet -IconType Symbols -ShowIconOnly | ||
$cfi2 = New-ConditionalFormattingIconSet -Range F:F -ConditionalFormat ThreeIconSet -IconType Symbols2 -ShowIconOnly | ||
|
||
$data | Export-Excel $xlfile -AutoSize -ConditionalFormat $cfi1, $cfi2 -Show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
if (-not (Get-command Import-Excel -ErrorAction SilentlyContinue)) { | ||
Import-Module $PSScriptRoot\..\ImportExcel.psd1 | ||
} | ||
|
||
Describe "Test New Conditional Formatting IconSet" -Tag ConditionalFormattingIconSet { | ||
BeforeEach { | ||
$xlFilename = "TestDrive:\ConditionalFormattingIconSet.xlsx" | ||
Remove-Item $xlFilename -ErrorAction SilentlyContinue | ||
|
||
$data = ConvertFrom-Csv @" | ||
Region,State,Other,Units,Price,InStock | ||
West,Texas,1,927,923.71,1 | ||
North,Tennessee,3,466,770.67,0 | ||
East,Florida,0,1520,458.68,1 | ||
East,Maine,1,1828,661.24,0 | ||
West,Virginia,1,465,053.58,1 | ||
North,Missouri,1,436,235.67,1 | ||
South,Kansas,0,214,992.47,1 | ||
North,North Dakota,1,789,640.72,0 | ||
South,Delaware,-1,712,508.55,1 | ||
"@ | ||
} | ||
|
||
It "Should set ThreeIconSet" { | ||
# $cfi1 = New-ConditionalFormattingIconSet -Range C:C -ConditionalFormat ThreeIconSet -IconType Symbols -ShowIconOnly | ||
$cfi1 = New-ConditionalFormattingIconSet -Range C:C -ConditionalFormat ThreeIconSet -IconType Symbols | ||
|
||
$data | Export-Excel $xlFilename -ConditionalFormat $cfi1 | ||
$actual = Import-Excel $xlFilename | ||
$actual.count | Should -Be 9 | ||
|
||
$xl = Open-ExcelPackage $xlFilename | ||
$xl.Workbook.Worksheets.Count | Should -Be 1 | ||
$targetSheet = $xl.Workbook.Worksheets[1] | ||
|
||
$targetSheet.Name | Should -Be "Sheet1" | ||
$targetSheet.ConditionalFormatting.Count | Should -Be 1 | ||
$targetSheet.ConditionalFormatting[0].Type | Should -Be "ThreeIconSet" | ||
$targetSheet.ConditionalFormatting[0].IconSet | Should -Be "Symbols" | ||
$targetSheet.ConditionalFormatting[0].Reverse | Should -BeFalse | ||
$targetSheet.ConditionalFormatting[0].ShowValue | Should -BeTrue | ||
|
||
Close-ExcelPackage $xl -NoSave | ||
} | ||
|
||
It "Should set ThreeIconSet with ShowOnlyIcon" { | ||
$cfi1 = New-ConditionalFormattingIconSet -Range C:C -ConditionalFormat ThreeIconSet -IconType Symbols -ShowIconOnly | ||
|
||
$data | Export-Excel $xlFilename -ConditionalFormat $cfi1 | ||
$actual = Import-Excel $xlFilename | ||
$actual.count | Should -Be 9 | ||
|
||
$xl = Open-ExcelPackage $xlFilename | ||
$xl.Workbook.Worksheets.Count | Should -Be 1 | ||
$targetSheet = $xl.Workbook.Worksheets[1] | ||
|
||
$targetSheet.Name | Should -Be "Sheet1" | ||
$targetSheet.ConditionalFormatting.Count | Should -Be 1 | ||
$targetSheet.ConditionalFormatting[0].Type | Should -Be "ThreeIconSet" | ||
$targetSheet.ConditionalFormatting[0].IconSet | Should -Be "Symbols" | ||
$targetSheet.ConditionalFormatting[0].Reverse | Should -BeFalse | ||
$targetSheet.ConditionalFormatting[0].ShowValue | Should -BeFalse | ||
|
||
Close-ExcelPackage $xl -NoSave | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters